summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
diff options
context:
space:
mode:
authorIdo Schimmel <idosch@mellanox.com>2017-10-22 23:11:45 +0200
committerDavid S. Miller <davem@davemloft.net>2017-10-23 05:23:06 +0100
commitd672aec45fd4a1e060109fbce6739ef91c3bd135 (patch)
tree0273856bd5b66a55f336a8f23b10180b62fa3516 /drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
parenta875a2ee2db8970dd93b8d287e35b8eba72f0a89 (diff)
mlxsw: spectrum: Add ability to query KVDL allocation size
The current KVDL allocation API allows the user to specify the requested number of entries, but the user has no way of knowing how many entries were actually allocated. This works because existing users (e.g., router) request the exact number they end up using. With the introduction of large adjacency groups, this will change, as the router will have the ability to choose from several allocation sizes, where larger allocations provide higher accuracy with respect to requested weights and better resilience against nexthop failures. One option is to have the router try several allocations of descending size until one succeeds, but a better way is to simply allow it to query the actual allocation size and then size its request accordingly. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c')
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
index 512537561483..266b3af6513c 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
@@ -164,6 +164,21 @@ void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index)
mlxsw_sp_kvdl_part_free(part, entry_index);
}
+int mlxsw_sp_kvdl_alloc_size_query(struct mlxsw_sp *mlxsw_sp,
+ unsigned int entry_count,
+ unsigned int *p_alloc_size)
+{
+ struct mlxsw_sp_kvdl_part *part;
+
+ part = mlxsw_sp_kvdl_alloc_size_part(mlxsw_sp->kvdl, entry_count);
+ if (IS_ERR(part))
+ return PTR_ERR(part);
+
+ *p_alloc_size = part->info->alloc_size;
+
+ return 0;
+}
+
static const struct mlxsw_sp_kvdl_part_info kvdl_parts_info[] = {
{
.part_index = 0,