blob: 680be80e6adfd0d18d82ce447175f57af4a5976b [file] [log] [blame]
Kristofer Jonsson3c6a2602022-03-10 11:17:29 +01001/*
2 * Copyright (c) 2022 ARM Limited.
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_INFO_H
22#define ETHOSU_NETWORK_INFO_H
23
24/****************************************************************************
25 * Includes
26 ****************************************************************************/
27
28#include "ethosu_core_interface.h"
Kristofer Jonsson442fefb2022-03-17 17:15:52 +010029#include "ethosu_mailbox.h"
Kristofer Jonsson3c6a2602022-03-10 11:17:29 +010030
31#include <linux/kref.h>
32#include <linux/types.h>
33#include <linux/completion.h>
34
35/****************************************************************************
36 * Types
37 ****************************************************************************/
38
39struct ethosu_device;
40struct ethosu_network;
41struct ethosu_uapi_network_info;
42
43struct ethosu_network_info {
44 struct ethosu_device *edev;
45 struct ethosu_network *net;
46 struct ethosu_uapi_network_info *uapi;
47 struct kref kref;
Kristofer Jonsson3c6a2602022-03-10 11:17:29 +010048 struct completion done;
49 int errno;
Kristofer Jonsson442fefb2022-03-17 17:15:52 +010050 struct ethosu_mailbox_msg msg;
Kristofer Jonsson3c6a2602022-03-10 11:17:29 +010051};
52
53/****************************************************************************
54 * Functions
55 ****************************************************************************/
56
57/**
58 * ethosu_network_info_create() - Create network info
59 *
60 * This function must be called in the context of a user space process.
61 *
62 * Return: Valid pointer on success, else ERR_PTR.
63 */
64struct ethosu_network_info *ethosu_network_info_create(
65 struct ethosu_device *edev,
66 struct ethosu_network *net,
67 struct ethosu_uapi_network_info *uapi);
68
69/**
70 * ethosu_network_info_get() - Get network info
71 */
72void ethosu_network_info_get(struct ethosu_network_info *info);
73
74/**
75 * ethosu_network_info_put() - Put network info
Kristofer Jonsson442fefb2022-03-17 17:15:52 +010076 *
77 * Return: 1 if object was removed, else 0.
Kristofer Jonsson3c6a2602022-03-10 11:17:29 +010078 */
Kristofer Jonsson442fefb2022-03-17 17:15:52 +010079int ethosu_network_info_put(struct ethosu_network_info *info);
Kristofer Jonsson3c6a2602022-03-10 11:17:29 +010080
81/**
82 * ethosu_network_info_wait() - Get network info
83 */
84int ethosu_network_info_wait(struct ethosu_network_info *info,
85 int timeout);
86
87/**
88 * ethosu_network_info_rsp() - Handle network info response.
89 */
90void ethosu_network_info_rsp(struct ethosu_device *edev,
91 struct ethosu_core_network_info_rsp *rsp);
92
93#endif /* ETHOSU_NETWORK_INFO_H */