Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 1 | /* |
Kristofer Jonsson | ec47704 | 2023-01-20 13:38:13 +0100 | [diff] [blame^] | 2 | * Copyright 2020,2022-2023 Arm Limited and/or its affiliates |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 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_NETWORK_H |
| 22 | #define ETHOSU_NETWORK_H |
| 23 | |
| 24 | /**************************************************************************** |
| 25 | * Includes |
| 26 | ****************************************************************************/ |
| 27 | |
| 28 | #include <linux/kref.h> |
| 29 | #include <linux/types.h> |
| 30 | |
| 31 | /**************************************************************************** |
| 32 | * Types |
| 33 | ****************************************************************************/ |
| 34 | |
| 35 | struct ethosu_buffer; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 36 | struct ethosu_uapi_network_create; |
| 37 | struct device; |
| 38 | struct file; |
| 39 | |
| 40 | struct ethosu_network { |
Kristofer Jonsson | ec47704 | 2023-01-20 13:38:13 +0100 | [diff] [blame^] | 41 | struct device *dev; |
| 42 | struct ethosu_mailbox *mailbox; |
| 43 | struct file *file; |
| 44 | struct kref kref; |
| 45 | struct ethosu_buffer *buf; |
| 46 | uint32_t index; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | /**************************************************************************** |
| 50 | * Functions |
| 51 | ****************************************************************************/ |
| 52 | |
| 53 | /** |
| 54 | * ethosu_network_create() - Create network |
| 55 | * |
| 56 | * This function must be called in the context of a user space process. |
| 57 | * |
| 58 | * Return: fd on success, else error code. |
| 59 | */ |
Kristofer Jonsson | ec47704 | 2023-01-20 13:38:13 +0100 | [diff] [blame^] | 60 | int ethosu_network_create(struct device *dev, |
| 61 | struct ethosu_mailbox *mailbox, |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 62 | struct ethosu_uapi_network_create *uapi); |
| 63 | |
| 64 | /** |
| 65 | * ethosu_network_get_from_fd() - Get network handle from fd |
| 66 | * |
| 67 | * This function must be called from a user space context. |
| 68 | * |
| 69 | * Return: Pointer on success, else ERR_PTR. |
| 70 | */ |
| 71 | struct ethosu_network *ethosu_network_get_from_fd(int fd); |
| 72 | |
| 73 | /** |
| 74 | * ethosu_network_get() - Get network |
| 75 | */ |
| 76 | void ethosu_network_get(struct ethosu_network *net); |
| 77 | |
| 78 | /** |
| 79 | * ethosu_network_put() - Put network |
Kristofer Jonsson | 442fefb | 2022-03-17 17:15:52 +0100 | [diff] [blame] | 80 | * |
| 81 | * Return: 1 if object was removed, else 0. |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 82 | */ |
Kristofer Jonsson | 442fefb | 2022-03-17 17:15:52 +0100 | [diff] [blame] | 83 | int ethosu_network_put(struct ethosu_network *net); |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 84 | |
| 85 | #endif /* ETHOSU_NETWORK_H */ |