Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 1 | /* |
| 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_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; |
| 36 | struct ethosu_device; |
| 37 | struct ethosu_uapi_network_create; |
| 38 | struct device; |
| 39 | struct file; |
| 40 | |
| 41 | struct ethosu_network { |
| 42 | struct ethosu_device *edev; |
| 43 | struct file *file; |
| 44 | struct kref kref; |
| 45 | struct ethosu_buffer *buf; |
| 46 | }; |
| 47 | |
| 48 | /**************************************************************************** |
| 49 | * Functions |
| 50 | ****************************************************************************/ |
| 51 | |
| 52 | /** |
| 53 | * ethosu_network_create() - Create network |
| 54 | * |
| 55 | * This function must be called in the context of a user space process. |
| 56 | * |
| 57 | * Return: fd on success, else error code. |
| 58 | */ |
| 59 | int ethosu_network_create(struct ethosu_device *edev, |
| 60 | struct ethosu_uapi_network_create *uapi); |
| 61 | |
| 62 | /** |
| 63 | * ethosu_network_get_from_fd() - Get network handle from fd |
| 64 | * |
| 65 | * This function must be called from a user space context. |
| 66 | * |
| 67 | * Return: Pointer on success, else ERR_PTR. |
| 68 | */ |
| 69 | struct ethosu_network *ethosu_network_get_from_fd(int fd); |
| 70 | |
| 71 | /** |
| 72 | * ethosu_network_get() - Get network |
| 73 | */ |
| 74 | void ethosu_network_get(struct ethosu_network *net); |
| 75 | |
| 76 | /** |
| 77 | * ethosu_network_put() - Put network |
| 78 | */ |
| 79 | void ethosu_network_put(struct ethosu_network *net); |
| 80 | |
| 81 | #endif /* ETHOSU_NETWORK_H */ |