2 * Copyright (c) 2019 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 #include <vlib/vlib.h>
18 #include <vnet/crypto/crypto.h>
21 show_crypto_engines_command_fn (vlib_main_t * vm,
22 unformat_input_t * input,
23 vlib_cli_command_t * cmd)
25 unformat_input_t _line_input, *line_input = &_line_input;
26 vnet_crypto_main_t *cm = &crypto_main;
27 vnet_crypto_engine_t *p;
29 if (unformat_user (input, unformat_line_input, line_input))
30 unformat_free (line_input);
32 if (vec_len (cm->engines) == 0)
34 vlib_cli_output (vm, "No crypto engines registered");
38 vlib_cli_output (vm, "%-20s%-8s%s", "Name", "Prio", "Description");
40 vec_foreach (p, cm->engines)
42 vlib_cli_output (vm, "%-20s%-8u%s", p->name, p->priority, p->desc);
49 VLIB_CLI_COMMAND (show_crypto_engines_command, static) =
51 .path = "show crypto engines",
52 .short_help = "show crypto engines",
53 .function = show_crypto_engines_command_fn,
57 show_crypto_handlers_command_fn (vlib_main_t * vm,
58 unformat_input_t * input, vlib_cli_command_t * cmd)
60 vnet_crypto_main_t *cm = &crypto_main;
61 unformat_input_t _line_input, *line_input = &_line_input;
64 if (unformat_user (input, unformat_line_input, line_input))
65 unformat_free (line_input);
67 vlib_cli_output (vm, "%-40s%-20s%s", "Name", "Active", "Candidates");
68 for (int i = 1; i < VNET_CRYPTO_N_OP_TYPES; i++)
70 vnet_crypto_op_type_data_t *otd = cm->opt_data + i;
71 vnet_crypto_engine_t *e;
74 vec_foreach (e, cm->engines)
76 if (e->ops_handlers[i] != 0)
77 s = format (s, "%U ", format_vnet_crypto_engine, e - cm->engines);
79 vlib_cli_output (vm, "%-40U%-20U%v", format_vnet_crypto_op, i,
80 format_vnet_crypto_engine, otd->active_engine_index,s);
87 VLIB_CLI_COMMAND (show_crypto_handlers_command, static) =
89 .path = "show crypto handlers",
90 .short_help = "show crypto handlers",
91 .function = show_crypto_handlers_command_fn,
96 * fd.io coding-style-patch-verification: ON
99 * eval: (c-set-style "gnu")