Remove buffer capacity, offset and resize in UAPI

The UAPI no longer supports the buffer capacity, offset and resize
functionality. Instead, the UAPI now only accepts a fixed size given at
the creation of the buffer. This change was made because the features
were not used and made the buffer handling more complicated. The user
knows how big buffers they need for their networks so they don't need
resize support or partial buffer usage support by having separate size
and capacity with an offset.

Without these features, the buffer instance no longer needs any IOCTL
call support so it has been removed. However, to still be able to check
the size of a buffer from its file descriptor, seek support has been
implemented so lseek and similar functions can be used to get the size.

The driver library's clear function that previously only reset the size
and offset values of the buffer will now clear the buffer content
instead.

These are breaking changes so the Linux kernel NPU driver version and
the driver library version have been given major version bumps. All the
tests and other applications affected by these changes have been updated
accordingly.

Change-Id: Ifc34cf04724a95853ad23fd7398dd286f73bcdab
Signed-off-by: Mikael Olsson <mikael.olsson@arm.com>
diff --git a/tests/run_inference_test.cpp b/tests/run_inference_test.cpp
index 6075d7a..6b17ac2 100644
--- a/tests/run_inference_test.cpp
+++ b/tests/run_inference_test.cpp
@@ -19,6 +19,7 @@
 #include <uapi/ethosu.h>
 
 #include <cstring>
+#include <errno.h>
 #include <iostream>
 #include <list>
 #include <memory>
@@ -69,6 +70,36 @@
     TEST_ASSERT(capabilities.hwId.architecture > SemanticVersion());
 }
 
+void testBufferSeek(const Device &device) {
+    try {
+        Buffer buf{device, 1024};
+
+        // SEEK_END should return the size of the buffer
+        TEST_ASSERT(lseek(buf.getFd(), 0, SEEK_END) == 1024);
+
+        // SEEK_SET is supported when moving the file pointer to the start
+        TEST_ASSERT(lseek(buf.getFd(), 0, SEEK_SET) == 0);
+
+        // SEEK_CUR is not supported
+        errno = 0;
+        TEST_ASSERT(lseek(buf.getFd(), 0, SEEK_CUR) == -1);
+        TEST_ASSERT(errno == EINVAL);
+
+        // Non-zero offset is not supported
+        errno = 0;
+        TEST_ASSERT(lseek(buf.getFd(), 1, SEEK_CUR) == -1);
+        TEST_ASSERT(errno == EINVAL);
+
+        errno = 0;
+        TEST_ASSERT(lseek(buf.getFd(), 2, SEEK_END) == -1);
+        TEST_ASSERT(errno == EINVAL);
+
+        errno = 0;
+        TEST_ASSERT(lseek(buf.getFd(), 3, SEEK_SET) == -1);
+        TEST_ASSERT(errno == EINVAL);
+    } catch (std::exception &e) { throw TestFailureException("Buffer seek test: ", e.what()); }
+}
+
 void testNetworkInfoNotExistentIndex(const Device &device) {
     try {
         Network(device, 0);
@@ -81,7 +112,6 @@
 void testNetworkInfoBuffer(const Device &device) {
     try {
         std::shared_ptr<Buffer> buffer = std::make_shared<Buffer>(device, sizeof(networkModelData));
-        buffer->resize(sizeof(networkModelData));
         std::memcpy(buffer->data(), networkModelData, sizeof(networkModelData));
         Network network(device, buffer);
 
@@ -93,7 +123,6 @@
 void testNetworkInfoUnparsableBuffer(const Device &device) {
     try {
         auto buffer = std::make_shared<Buffer>(device, sizeof(networkModelData) / 4);
-        buffer->resize(sizeof(networkModelData) / 4);
         std::memcpy(buffer->data(), networkModelData + sizeof(networkModelData) / 4, sizeof(networkModelData) / 4);
 
         try {
@@ -122,7 +151,6 @@
 void testRunInferenceBuffer(const Device &device) {
     try {
         auto networkBuffer = std::make_shared<Buffer>(device, sizeof(networkModelData));
-        networkBuffer->resize(sizeof(networkModelData));
         std::memcpy(networkBuffer->data(), networkModelData, sizeof(networkModelData));
         auto network = std::make_shared<Network>(device, networkBuffer);
 
@@ -130,7 +158,6 @@
         std::vector<std::shared_ptr<Buffer>> outputBuffers;
 
         auto inputBuffer = std::make_shared<Buffer>(device, sizeof(inputData));
-        inputBuffer->resize(sizeof(inputData));
         std::memcpy(inputBuffer->data(), inputData, sizeof(inputData));
 
         inputBuffers.push_back(inputBuffer);
@@ -168,6 +195,7 @@
         testPing(device);
         testDriverVersion(device);
         testCapabilties(device);
+        testBufferSeek(device);
         testNetworkInvalidType(device);
         testNetworkInfoNotExistentIndex(device);
         testNetworkInfoBuffer(device);