hash: add support for hashing infra
[vpp.git] / src / vnet / hash / cli.c
1 /*
2  * SPDX-License-Identifier: Apache-2.0
3  * Copyright(c) 2021 Cisco Systems, Inc.
4  */
5
6 #include <vnet/vnet.h>
7 #include <vnet/hash/hash.h>
8
9 static clib_error_t *
10 show_hash (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
11 {
12   clib_error_t *error = 0;
13   vnet_hash_main_t *hm = &vnet_hash_main;
14   vnet_hash_function_registration_t *hash;
15
16   hash = hm->hash_registrations;
17
18   vlib_cli_output (vm, "%-25s%-8s%s", "Name", "Prio", "Description");
19   while (hash)
20     {
21       vlib_cli_output (vm, "%-25s%-8u%s", hash->name, hash->priority,
22                        hash->description);
23       hash = hash->next;
24     }
25
26   return (error);
27 }
28
29 VLIB_CLI_COMMAND (cmd_show_hash, static) = {
30   .path = "show hash",
31   .short_help = "show hash",
32   .function = show_hash,
33 };