blob: 8ee6818c788dbc0e4b345951203e65865af29627 [file] [log] [blame]
Kristofer Jonsson116a6352020-08-20 17:25:23 +02001/*
Kristofer Jonsson3c6a2602022-03-10 11:17:29 +01002 * Copyright (c) 2020,2022 Arm Limited.
Kristofer Jonsson116a6352020-08-20 17:25:23 +02003 *
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
35struct ethosu_buffer;
36struct ethosu_device;
37struct ethosu_uapi_network_create;
38struct device;
39struct file;
40
41struct ethosu_network {
42 struct ethosu_device *edev;
43 struct file *file;
44 struct kref kref;
45 struct ethosu_buffer *buf;
Kristofer Jonsson35de9e62022-03-08 13:25:45 +010046 uint32_t index;
Kristofer Jonsson116a6352020-08-20 17:25:23 +020047};
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 */
60int ethosu_network_create(struct ethosu_device *edev,
61 struct ethosu_uapi_network_create *uapi);
62
63/**
64 * ethosu_network_get_from_fd() - Get network handle from fd
65 *
66 * This function must be called from a user space context.
67 *
68 * Return: Pointer on success, else ERR_PTR.
69 */
70struct ethosu_network *ethosu_network_get_from_fd(int fd);
71
72/**
73 * ethosu_network_get() - Get network
74 */
75void ethosu_network_get(struct ethosu_network *net);
76
77/**
78 * ethosu_network_put() - Put network
Kristofer Jonsson442fefb2022-03-17 17:15:52 +010079 *
80 * Return: 1 if object was removed, else 0.
Kristofer Jonsson116a6352020-08-20 17:25:23 +020081 */
Kristofer Jonsson442fefb2022-03-17 17:15:52 +010082int ethosu_network_put(struct ethosu_network *net);
Kristofer Jonsson116a6352020-08-20 17:25:23 +020083
84#endif /* ETHOSU_NETWORK_H */