summaryrefslogtreecommitdiff
path: root/arch/mips/mach-octeon/include/mach/cvmx-pki-resources.h
blob: 79b99b0bd7c2be50d0c0b5861f281aa464d6aa9d (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
146
147
148
149
150
151
152
153
154
155
156
157
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) 2020 Marvell International Ltd.
 *
 * Resource management for PKI resources.
 */

#ifndef __CVMX_PKI_RESOURCES_H__
#define __CVMX_PKI_RESOURCES_H__

/**
 * This function allocates/reserves a style from pool of global styles per node.
 * @param node	 node to allocate style from.
 * @param style	 style to allocate, if -1 it will be allocated
		 first available style from style resource. If index is positive
		 number and in range, it will try to allocate specified style.
 * @return	 style number on success, -1 on failure.
 */
int cvmx_pki_style_alloc(int node, int style);

/**
 * This function allocates/reserves a cluster group from per node
   cluster group resources.
 * @param node		node to allocate cluster group from.
   @param cl_grp	cluster group to allocate/reserve, if -1 ,
			allocate any available cluster group.
 * @return		cluster group number or -1 on failure
 */
int cvmx_pki_cluster_grp_alloc(int node, int cl_grp);

/**
 * This function allocates/reserves a cluster from per node
   cluster resources.
 * @param node		node to allocate cluster group from.
   @param cluster_mask	mask of clusters  to allocate/reserve, if -1 ,
			allocate any available clusters.
 * @param num_clusters	number of clusters that will be allocated
 */
int cvmx_pki_cluster_alloc(int node, int num_clusters, u64 *cluster_mask);

/**
 * This function allocates/reserves a pcam entry from node
 * @param node		node to allocate pcam entry from.
   @param index	index of pacm entry (0-191), if -1 ,
			allocate any available pcam entry.
 * @param bank		pcam bank where to allocate/reserve pcan entry from
 * @param cluster_mask  mask of clusters from which pcam entry is needed.
 * @return		pcam entry of -1 on failure
 */
int cvmx_pki_pcam_entry_alloc(int node, int index, int bank, u64 cluster_mask);

/**
 * This function allocates/reserves QPG table entries per node.
 * @param node		node number.
 * @param base_offset	base_offset in qpg table. If -1, first available
			qpg base_offset will be allocated. If base_offset is positive
			number and in range, it will try to allocate specified base_offset.
   @param count		number of consecutive qpg entries to allocate. They will be consecutive
			from base offset.
 * @return		qpg table base offset number on success, -1 on failure.
 */
int cvmx_pki_qpg_entry_alloc(int node, int base_offset, int count);

/**
 * This function frees a style from pool of global styles per node.
 * @param node	 node to free style from.
 * @param style	 style to free
 * @return	 0 on success, -1 on failure.
 */
int cvmx_pki_style_free(int node, int style);

/**
 * This function frees a cluster group from per node
   cluster group resources.
 * @param node		node to free cluster group from.
   @param cl_grp	cluster group to free
 * @return		0 on success or -1 on failure
 */
int cvmx_pki_cluster_grp_free(int node, int cl_grp);

/**
 * This function frees QPG table entries per node.
 * @param node		node number.
 * @param base_offset	base_offset in qpg table. If -1, first available
 *			qpg base_offset will be allocated. If base_offset is positive
 *			number and in range, it will try to allocate specified base_offset.
 * @param count		number of consecutive qpg entries to allocate. They will be consecutive
 *			from base offset.
 * @return		qpg table base offset number on success, -1 on failure.
 */
int cvmx_pki_qpg_entry_free(int node, int base_offset, int count);

/**
 * This function frees  clusters  from per node
   clusters resources.
 * @param node		node to free clusters from.
 * @param cluster_mask  mask of clusters need freeing
 * @return		0 on success or -1 on failure
 */
int cvmx_pki_cluster_free(int node, u64 cluster_mask);

/**
 * This function frees a pcam entry from node
 * @param node		node to allocate pcam entry from.
   @param index	index of pacm entry (0-191) needs to be freed.
 * @param bank		pcam bank where to free pcam entry from
 * @param cluster_mask  mask of clusters from which pcam entry is freed.
 * @return		0 on success OR -1 on failure
 */
int cvmx_pki_pcam_entry_free(int node, int index, int bank, u64 cluster_mask);

/**
 * This function allocates/reserves a bpid from pool of global bpid per node.
 * @param node	node to allocate bpid from.
 * @param bpid	bpid  to allocate, if -1 it will be allocated
 *		first available boid from bpid resource. If index is positive
 *		number and in range, it will try to allocate specified bpid.
 * @return	bpid number on success,
 *		-1 on alloc failure.
 *		-2 on resource already reserved.
 */
int cvmx_pki_bpid_alloc(int node, int bpid);

/**
 * This function frees a bpid from pool of global bpid per node.
 * @param node	 node to free bpid from.
 * @param bpid	 bpid to free
 * @return	 0 on success, -1 on failure or
 */
int cvmx_pki_bpid_free(int node, int bpid);

/**
 * This function frees all the PKI software resources
 * (clusters, styles, qpg_entry, pcam_entry etc) for the specified node
 */

/**
 * This function allocates/reserves an index from pool of global MTAG-IDX per node.
 * @param node	node to allocate index from.
 * @param idx	index  to allocate, if -1 it will be allocated
 * @return	MTAG index number on success,
 *		-1 on alloc failure.
 *		-2 on resource already reserved.
 */
int cvmx_pki_mtag_idx_alloc(int node, int idx);

/**
 * This function frees an index from pool of global MTAG-IDX per node.
 * @param node	 node to free bpid from.
 * @param bpid	 bpid to free
 * @return	 0 on success, -1 on failure or
 */
int cvmx_pki_mtag_idx_free(int node, int idx);

void __cvmx_pki_global_rsrc_free(int node);

#endif /*  __CVM_PKI_RESOURCES_H__ */