Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 1 | /* |
Mikael Olsson | d4ad9e5 | 2024-02-07 11:22:26 +0100 | [diff] [blame] | 2 | * SPDX-FileCopyrightText: Copyright 2020, 2022-2024 Arm Limited and/or its affiliates <open-source-office@arm.com> |
Mikael Olsson | c081e59 | 2023-10-30 11:10:56 +0100 | [diff] [blame] | 3 | * SPDX-License-Identifier: GPL-2.0-only |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 4 | * |
| 5 | * This program is free software and is provided to you under the terms of the |
| 6 | * GNU General Public License version 2 as published by the Free Software |
| 7 | * Foundation, and any use by you of this program is subject to the terms |
| 8 | * of such GNU licence. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, you can access it online at |
| 17 | * http://www.gnu.org/licenses/gpl-2.0.html. |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 18 | */ |
| 19 | |
Mikael Olsson | 16be285 | 2024-02-12 09:56:56 +0100 | [diff] [blame^] | 20 | #ifndef ETHOSU_RPMSG_NETWORK_H |
| 21 | #define ETHOSU_RPMSG_NETWORK_H |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 22 | |
| 23 | /**************************************************************************** |
| 24 | * Includes |
| 25 | ****************************************************************************/ |
| 26 | |
| 27 | #include <linux/kref.h> |
| 28 | #include <linux/types.h> |
| 29 | |
| 30 | /**************************************************************************** |
| 31 | * Types |
| 32 | ****************************************************************************/ |
| 33 | |
| 34 | struct ethosu_buffer; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 35 | struct ethosu_uapi_network_create; |
| 36 | struct device; |
| 37 | struct file; |
| 38 | |
Mikael Olsson | 16be285 | 2024-02-12 09:56:56 +0100 | [diff] [blame^] | 39 | struct ethosu_rpmsg_network { |
| 40 | struct device *dev; |
| 41 | struct ethosu_rpmsg_mailbox *mailbox; |
| 42 | struct file *file; |
| 43 | struct kref kref; |
| 44 | struct ethosu_dma_mem *dma_mem; |
| 45 | uint32_t index; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | /**************************************************************************** |
| 49 | * Functions |
| 50 | ****************************************************************************/ |
| 51 | |
| 52 | /** |
Mikael Olsson | 16be285 | 2024-02-12 09:56:56 +0100 | [diff] [blame^] | 53 | * ethosu_rpmsg_network_create() - Create network |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 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 | */ |
Mikael Olsson | 16be285 | 2024-02-12 09:56:56 +0100 | [diff] [blame^] | 59 | int ethosu_rpmsg_network_create(struct device *dev, |
| 60 | struct ethosu_rpmsg_mailbox *mailbox, |
| 61 | struct ethosu_uapi_network_create *uapi); |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 62 | |
| 63 | /** |
Mikael Olsson | 16be285 | 2024-02-12 09:56:56 +0100 | [diff] [blame^] | 64 | * ethosu_rpmsg_network_get_from_fd() - Get network handle from fd |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 65 | * |
| 66 | * This function must be called from a user space context. |
| 67 | * |
| 68 | * Return: Pointer on success, else ERR_PTR. |
| 69 | */ |
Mikael Olsson | 16be285 | 2024-02-12 09:56:56 +0100 | [diff] [blame^] | 70 | struct ethosu_rpmsg_network *ethosu_rpmsg_network_get_from_fd(int fd); |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 71 | |
| 72 | /** |
Mikael Olsson | 16be285 | 2024-02-12 09:56:56 +0100 | [diff] [blame^] | 73 | * ethosu_rpmsg_network_get() - Get network |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 74 | */ |
Mikael Olsson | 16be285 | 2024-02-12 09:56:56 +0100 | [diff] [blame^] | 75 | void ethosu_rpmsg_network_get(struct ethosu_rpmsg_network *net); |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 76 | |
| 77 | /** |
Mikael Olsson | 16be285 | 2024-02-12 09:56:56 +0100 | [diff] [blame^] | 78 | * ethosu_rpmsg_network_put() - Put network |
Kristofer Jonsson | 442fefb | 2022-03-17 17:15:52 +0100 | [diff] [blame] | 79 | * |
| 80 | * Return: 1 if object was removed, else 0. |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 81 | */ |
Mikael Olsson | 16be285 | 2024-02-12 09:56:56 +0100 | [diff] [blame^] | 82 | int ethosu_rpmsg_network_put(struct ethosu_rpmsg_network *net); |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 83 | |
Mikael Olsson | 16be285 | 2024-02-12 09:56:56 +0100 | [diff] [blame^] | 84 | #endif /* ETHOSU_RPMSG_NETWORK_H */ |