blob: 79b99b0bd7c2be50d0c0b5861f281aa464d6aa9d [file] [log] [blame]
Aaron Williams4fd1e552021-04-23 19:56:32 +02001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2020 Marvell International Ltd.
4 *
5 * Resource management for PKI resources.
6 */
7
8#ifndef __CVMX_PKI_RESOURCES_H__
9#define __CVMX_PKI_RESOURCES_H__
10
11/**
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.
18 */
19int cvmx_pki_style_alloc(int node, int style);
20
21/**
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
28 */
29int cvmx_pki_cluster_grp_alloc(int node, int cl_grp);
30
31/**
32 * This function allocates/reserves a cluster from per node
33 cluster resources.
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
38 */
39int cvmx_pki_cluster_alloc(int node, int num_clusters, u64 *cluster_mask);
40
41/**
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
49 */
50int cvmx_pki_pcam_entry_alloc(int node, int index, int bank, u64 cluster_mask);
51
52/**
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
59 from base offset.
60 * @return qpg table base offset number on success, -1 on failure.
61 */
62int cvmx_pki_qpg_entry_alloc(int node, int base_offset, int count);
63
64/**
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.
69 */
70int cvmx_pki_style_free(int node, int style);
71
72/**
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
78 */
79int cvmx_pki_cluster_grp_free(int node, int cl_grp);
80
81/**
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
88 * from base offset.
89 * @return qpg table base offset number on success, -1 on failure.
90 */
91int cvmx_pki_qpg_entry_free(int node, int base_offset, int count);
92
93/**
94 * This function frees clusters from per node
95 clusters resources.
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
99 */
100int cvmx_pki_cluster_free(int node, u64 cluster_mask);
101
102/**
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
109 */
110int cvmx_pki_pcam_entry_free(int node, int index, int bank, u64 cluster_mask);
111
112/**
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.
121 */
122int cvmx_pki_bpid_alloc(int node, int bpid);
123
124/**
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
129 */
130int cvmx_pki_bpid_free(int node, int bpid);
131
132/**
133 * This function frees all the PKI software resources
134 * (clusters, styles, qpg_entry, pcam_entry etc) for the specified node
135 */
136
137/**
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.
144 */
145int cvmx_pki_mtag_idx_alloc(int node, int idx);
146
147/**
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
152 */
153int cvmx_pki_mtag_idx_free(int node, int idx);
154
155void __cvmx_pki_global_rsrc_free(int node);
156
157#endif /* __CVM_PKI_RESOURCES_H__ */