blob: 3c60166b99dbc0020362ea3e818758c12ca5c49a [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.
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010017 * Return: style number on success, -1 on failure.
Aaron Williams4fd1e552021-04-23 19:56:32 +020018 */
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.
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010027 * Return: cluster group number or -1 on failure
Aaron Williams4fd1e552021-04-23 19:56:32 +020028 */
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.
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010048 * Return: pcam entry of -1 on failure
Aaron Williams4fd1e552021-04-23 19:56:32 +020049 */
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.
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010060 * Return: qpg table base offset number on success, -1 on failure.
Aaron Williams4fd1e552021-04-23 19:56:32 +020061 */
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
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010068 * Return: 0 on success, -1 on failure.
Aaron Williams4fd1e552021-04-23 19:56:32 +020069 */
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
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010077 * Return: 0 on success or -1 on failure
Aaron Williams4fd1e552021-04-23 19:56:32 +020078 */
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.
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010089 * Return: qpg table base offset number on success, -1 on failure.
Aaron Williams4fd1e552021-04-23 19:56:32 +020090 */
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
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010098 * Return: 0 on success or -1 on failure
Aaron Williams4fd1e552021-04-23 19:56:32 +020099 */
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.
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100108 * Return: 0 on success OR -1 on failure
Aaron Williams4fd1e552021-04-23 19:56:32 +0200109 */
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.
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100118 * Return: bpid number on success,
Aaron Williams4fd1e552021-04-23 19:56:32 +0200119 * -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
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100128 * Return: 0 on success, -1 on failure or
Aaron Williams4fd1e552021-04-23 19:56:32 +0200129 */
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
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100141 * Return: MTAG index number on success,
Aaron Williams4fd1e552021-04-23 19:56:32 +0200142 * -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
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100151 * Return: 0 on success, -1 on failure or
Aaron Williams4fd1e552021-04-23 19:56:32 +0200152 */
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__ */