Aaron Williams | 4fd1e55 | 2021-04-23 19:56:32 +0200 | [diff] [blame] | 1 | /* 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 17 | * Return: style number on success, -1 on failure. |
Aaron Williams | 4fd1e55 | 2021-04-23 19:56:32 +0200 | [diff] [blame] | 18 | */ |
| 19 | int 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 27 | * Return: cluster group number or -1 on failure |
Aaron Williams | 4fd1e55 | 2021-04-23 19:56:32 +0200 | [diff] [blame] | 28 | */ |
| 29 | int 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 | */ |
| 39 | int 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 48 | * Return: pcam entry of -1 on failure |
Aaron Williams | 4fd1e55 | 2021-04-23 19:56:32 +0200 | [diff] [blame] | 49 | */ |
| 50 | int 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 60 | * Return: qpg table base offset number on success, -1 on failure. |
Aaron Williams | 4fd1e55 | 2021-04-23 19:56:32 +0200 | [diff] [blame] | 61 | */ |
| 62 | int 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 68 | * Return: 0 on success, -1 on failure. |
Aaron Williams | 4fd1e55 | 2021-04-23 19:56:32 +0200 | [diff] [blame] | 69 | */ |
| 70 | int 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 77 | * Return: 0 on success or -1 on failure |
Aaron Williams | 4fd1e55 | 2021-04-23 19:56:32 +0200 | [diff] [blame] | 78 | */ |
| 79 | int 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 89 | * Return: qpg table base offset number on success, -1 on failure. |
Aaron Williams | 4fd1e55 | 2021-04-23 19:56:32 +0200 | [diff] [blame] | 90 | */ |
| 91 | int 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 98 | * Return: 0 on success or -1 on failure |
Aaron Williams | 4fd1e55 | 2021-04-23 19:56:32 +0200 | [diff] [blame] | 99 | */ |
| 100 | int 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 108 | * Return: 0 on success OR -1 on failure |
Aaron Williams | 4fd1e55 | 2021-04-23 19:56:32 +0200 | [diff] [blame] | 109 | */ |
| 110 | int 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 118 | * Return: bpid number on success, |
Aaron Williams | 4fd1e55 | 2021-04-23 19:56:32 +0200 | [diff] [blame] | 119 | * -1 on alloc failure. |
| 120 | * -2 on resource already reserved. |
| 121 | */ |
| 122 | int 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 128 | * Return: 0 on success, -1 on failure or |
Aaron Williams | 4fd1e55 | 2021-04-23 19:56:32 +0200 | [diff] [blame] | 129 | */ |
| 130 | int 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 141 | * Return: MTAG index number on success, |
Aaron Williams | 4fd1e55 | 2021-04-23 19:56:32 +0200 | [diff] [blame] | 142 | * -1 on alloc failure. |
| 143 | * -2 on resource already reserved. |
| 144 | */ |
| 145 | int 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 151 | * Return: 0 on success, -1 on failure or |
Aaron Williams | 4fd1e55 | 2021-04-23 19:56:32 +0200 | [diff] [blame] | 152 | */ |
| 153 | int cvmx_pki_mtag_idx_free(int node, int idx); |
| 154 | |
| 155 | void __cvmx_pki_global_rsrc_free(int node); |
| 156 | |
| 157 | #endif /* __CVM_PKI_RESOURCES_H__ */ |