1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020 Marvell International Ltd.
5 * Resource management for PKI resources.
8 #ifndef __CVMX_PKI_RESOURCES_H__
9 #define __CVMX_PKI_RESOURCES_H__
12 * This function allocates/reserves a style from pool of global styles per node.
13 * @param node node to allocate style from.
14 * @param style style to allocate, if -1 it will be allocated
15 first available style from style resource. If index is positive
16 number and in range, it will try to allocate specified style.
17 * Return: style number on success, -1 on failure.
19 int cvmx_pki_style_alloc(int node, int style);
22 * This function allocates/reserves a cluster group from per node
23 cluster group resources.
24 * @param node node to allocate cluster group from.
25 @param cl_grp cluster group to allocate/reserve, if -1 ,
26 allocate any available cluster group.
27 * Return: cluster group number or -1 on failure
29 int cvmx_pki_cluster_grp_alloc(int node, int cl_grp);
32 * This function allocates/reserves a cluster from per node
34 * @param node node to allocate cluster group from.
35 @param cluster_mask mask of clusters to allocate/reserve, if -1 ,
36 allocate any available clusters.
37 * @param num_clusters number of clusters that will be allocated
39 int cvmx_pki_cluster_alloc(int node, int num_clusters, u64 *cluster_mask);
42 * This function allocates/reserves a pcam entry from node
43 * @param node node to allocate pcam entry from.
44 @param index index of pacm entry (0-191), if -1 ,
45 allocate any available pcam entry.
46 * @param bank pcam bank where to allocate/reserve pcan entry from
47 * @param cluster_mask mask of clusters from which pcam entry is needed.
48 * Return: pcam entry of -1 on failure
50 int cvmx_pki_pcam_entry_alloc(int node, int index, int bank, u64 cluster_mask);
53 * This function allocates/reserves QPG table entries per node.
54 * @param node node number.
55 * @param base_offset base_offset in qpg table. If -1, first available
56 qpg base_offset will be allocated. If base_offset is positive
57 number and in range, it will try to allocate specified base_offset.
58 @param count number of consecutive qpg entries to allocate. They will be consecutive
60 * Return: qpg table base offset number on success, -1 on failure.
62 int cvmx_pki_qpg_entry_alloc(int node, int base_offset, int count);
65 * This function frees a style from pool of global styles per node.
66 * @param node node to free style from.
67 * @param style style to free
68 * Return: 0 on success, -1 on failure.
70 int cvmx_pki_style_free(int node, int style);
73 * This function frees a cluster group from per node
74 cluster group resources.
75 * @param node node to free cluster group from.
76 @param cl_grp cluster group to free
77 * Return: 0 on success or -1 on failure
79 int cvmx_pki_cluster_grp_free(int node, int cl_grp);
82 * This function frees QPG table entries per node.
83 * @param node node number.
84 * @param base_offset base_offset in qpg table. If -1, first available
85 * qpg base_offset will be allocated. If base_offset is positive
86 * number and in range, it will try to allocate specified base_offset.
87 * @param count number of consecutive qpg entries to allocate. They will be consecutive
89 * Return: qpg table base offset number on success, -1 on failure.
91 int cvmx_pki_qpg_entry_free(int node, int base_offset, int count);
94 * This function frees clusters from per node
96 * @param node node to free clusters from.
97 * @param cluster_mask mask of clusters need freeing
98 * Return: 0 on success or -1 on failure
100 int cvmx_pki_cluster_free(int node, u64 cluster_mask);
103 * This function frees a pcam entry from node
104 * @param node node to allocate pcam entry from.
105 @param index index of pacm entry (0-191) needs to be freed.
106 * @param bank pcam bank where to free pcam entry from
107 * @param cluster_mask mask of clusters from which pcam entry is freed.
108 * Return: 0 on success OR -1 on failure
110 int cvmx_pki_pcam_entry_free(int node, int index, int bank, u64 cluster_mask);
113 * This function allocates/reserves a bpid from pool of global bpid per node.
114 * @param node node to allocate bpid from.
115 * @param bpid bpid to allocate, if -1 it will be allocated
116 * first available boid from bpid resource. If index is positive
117 * number and in range, it will try to allocate specified bpid.
118 * Return: bpid number on success,
119 * -1 on alloc failure.
120 * -2 on resource already reserved.
122 int cvmx_pki_bpid_alloc(int node, int bpid);
125 * This function frees a bpid from pool of global bpid per node.
126 * @param node node to free bpid from.
127 * @param bpid bpid to free
128 * Return: 0 on success, -1 on failure or
130 int cvmx_pki_bpid_free(int node, int bpid);
133 * This function frees all the PKI software resources
134 * (clusters, styles, qpg_entry, pcam_entry etc) for the specified node
138 * This function allocates/reserves an index from pool of global MTAG-IDX per node.
139 * @param node node to allocate index from.
140 * @param idx index to allocate, if -1 it will be allocated
141 * Return: MTAG index number on success,
142 * -1 on alloc failure.
143 * -2 on resource already reserved.
145 int cvmx_pki_mtag_idx_alloc(int node, int idx);
148 * This function frees an index from pool of global MTAG-IDX per node.
149 * @param node node to free bpid from.
150 * @param bpid bpid to free
151 * Return: 0 on success, -1 on failure or
153 int cvmx_pki_mtag_idx_free(int node, int idx);
155 void __cvmx_pki_global_rsrc_free(int node);
157 #endif /* __CVM_PKI_RESOURCES_H__ */