aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c
blob: 89c7b492030958d5cbfd81b8953dc09500b4dac0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright(c) 2010-2018 Intel Corporation
 */

#include "opae_ifpga_hw_api.h"
#include "ifpga_api.h"

int opae_manager_ifpga_get_prop(struct opae_manager *mgr,
				struct feature_prop *prop)
{
	struct ifpga_fme_hw *fme;

	if (!mgr || !mgr->data)
		return -EINVAL;

	fme = mgr->data;

	return ifpga_get_prop(fme->parent, FEATURE_FIU_ID_FME, 0, prop);
}

int opae_manager_ifpga_set_prop(struct opae_manager *mgr,
				struct feature_prop *prop)
{
	struct ifpga_fme_hw *fme;

	if (!mgr || !mgr->data)
		return -EINVAL;

	fme = mgr->data;

	return ifpga_set_prop(fme->parent, FEATURE_FIU_ID_FME, 0, prop);
}

int opae_manager_ifpga_get_info(struct opae_manager *mgr,
				struct fpga_fme_info *fme_info)
{
	struct ifpga_fme_hw *fme;

	if (!mgr || !mgr->data || !fme_info)
		return -EINVAL;

	fme = mgr->data;

	spinlock_lock(&fme->lock);
	fme_info->capability = fme->capability;
	spinlock_unlock(&fme->lock);

	return 0;
}

int opae_manager_ifpga_set_err_irq(struct opae_manager *mgr,
				   struct fpga_fme_err_irq_set *err_irq_set)
{
	struct ifpga_fme_hw *fme;

	if (!mgr || !mgr->data)
		return -EINVAL;

	fme = mgr->data;

	return ifpga_set_irq(fme->parent, FEATURE_FIU_ID_FME, 0,
			     IFPGA_FME_FEATURE_ID_GLOBAL_ERR, err_irq_set);
}

int opae_bridge_ifpga_get_prop(struct opae_bridge *br,
			       struct feature_prop *prop)
{
	struct ifpga_port_hw *port;

	if (!br || !br->data)
		return -EINVAL;

	port = br->data;

	return ifpga_get_prop(port->parent, FEATURE_FIU_ID_PORT,
			      port->port_id, prop);
}

int opae_bridge_ifpga_set_prop(struct opae_bridge *br,
			       struct feature_prop *prop)
{
	struct ifpga_port_hw *port;

	if (!br || !br->data)
		return -EINVAL;

	port = br->data;

	return ifpga_set_prop(port->parent, FEATURE_FIU_ID_PORT,
			      port->port_id, prop);
}

int opae_bridge_ifpga_get_info(struct opae_bridge *br,
			       struct fpga_port_info *port_info)
{
	struct ifpga_port_hw *port;

	if (!br || !br->data || !port_info)
		return -EINVAL;

	port = br->data;

	spinlock_lock(&port->lock);
	port_info->capability = port->capability;
	port_info->num_uafu_irqs = port->num_uafu_irqs;
	spinlock_unlock(&port->lock);

	return 0;
}

int opae_bridge_ifpga_get_region_info(struct opae_bridge *br,
				      struct fpga_port_region_info *info)
{
	struct ifpga_port_hw *port;

	if (!br || !br->data || !info)
		return -EINVAL;

	/* Only support STP region now */
	if (info->index != PORT_REGION_INDEX_STP)
		return -EINVAL;

	port = br->data;

	spinlock_lock(&port->lock);
	info->addr = port->stp_addr;
	info->size = port->stp_size;
	spinlock_unlock(&port->lock);

	return 0;
}

int opae_bridge_ifpga_set_err_irq(struct opae_bridge *br,
				  struct fpga_port_err_irq_set *err_irq_set)
{
	struct ifpga_port_hw *port;

	if (!br || !br->data)
		return -EINVAL;

	port = br->data;

	return ifpga_set_irq(port->parent, FEATURE_FIU_ID_PORT, port->port_id,
			     IFPGA_PORT_FEATURE_ID_ERROR, err_irq_set);
}