diff options
Diffstat (limited to 'src/vnet/crypto/cli.c')
-rw-r--r-- | src/vnet/crypto/cli.c | 98 |
1 files changed, 36 insertions, 62 deletions
diff --git a/src/vnet/crypto/cli.c b/src/vnet/crypto/cli.c index a6098a18e11..2ca66f228c3 100644 --- a/src/vnet/crypto/cli.c +++ b/src/vnet/crypto/cli.c @@ -36,16 +36,13 @@ show_crypto_engines_command_fn (vlib_main_t * vm, } vlib_cli_output (vm, "%-20s%-8s%s", "Name", "Prio", "Description"); - /* *INDENT-OFF* */ vec_foreach (p, cm->engines) { vlib_cli_output (vm, "%-20s%-8u%s", p->name, p->priority, p->desc); } - /* *INDENT-ON* */ return 0; } -/* *INDENT-OFF* */ VLIB_CLI_COMMAND (show_crypto_engines_command, static) = { .path = "show crypto engines", @@ -67,7 +64,7 @@ format_vnet_crypto_engine_candidates (u8 * s, va_list * args) { vec_foreach (e, cm->engines) { - if (e->enqueue_handlers[id] && e->dequeue_handlers[id]) + if (e->enqueue_handlers[id] && e->dequeue_handler) { s = format (s, "%U", format_vnet_crypto_engine, e - cm->engines); if (ei == e - cm->engines) @@ -145,20 +142,18 @@ show_crypto_handlers_command_fn (vlib_main_t * vm, "Chained"); for (i = 0; i < VNET_CRYPTO_N_ALGS; i++) - vlib_cli_output (vm, "%-16U%U", format_vnet_crypto_alg, i, + vlib_cli_output (vm, "%-20U%U", format_vnet_crypto_alg, i, format_vnet_crypto_handlers, i); return 0; } -/* *INDENT-OFF* */ VLIB_CLI_COMMAND (show_crypto_handlers_command, static) = { .path = "show crypto handlers", .short_help = "show crypto handlers", .function = show_crypto_handlers_command_fn, }; -/* *INDENT-ON* */ static clib_error_t * set_crypto_handler_command_fn (vlib_main_t * vm, @@ -209,13 +204,11 @@ set_crypto_handler_command_fn (vlib_main_t * vm, char *key; u8 *value; - /* *INDENT-OFF* */ hash_foreach_mem (key, value, cm->alg_index_by_name, ({ (void) value; rc += vnet_crypto_set_handler2 (key, engine, oct); })); - /* *INDENT-ON* */ if (rc) vlib_cli_output (vm, "failed to set crypto engine!"); @@ -241,7 +234,6 @@ done: return error; } -/* *INDENT-OFF* */ VLIB_CLI_COMMAND (set_crypto_handler_command, static) = { .path = "set crypto handler", @@ -249,7 +241,6 @@ VLIB_CLI_COMMAND (set_crypto_handler_command, static) = " [simple|chained]", .function = set_crypto_handler_command_fn, }; -/* *INDENT-ON* */ static u8 * format_vnet_crypto_async_handlers (u8 * s, va_list * args) @@ -300,14 +291,12 @@ show_crypto_async_handlers_command_fn (vlib_main_t * vm, return 0; } -/* *INDENT-OFF* */ VLIB_CLI_COMMAND (show_crypto_async_handlers_command, static) = { .path = "show crypto async handlers", .short_help = "show crypto async handlers", .function = show_crypto_async_handlers_command_fn, }; -/* *INDENT-ON* */ static clib_error_t * @@ -316,7 +305,6 @@ show_crypto_async_status_command_fn (vlib_main_t * vm, vlib_cli_command_t * cmd) { vnet_crypto_main_t *cm = &crypto_main; - u32 skip_master = vlib_num_workers () > 0; vlib_thread_main_t *tm = vlib_get_thread_main (); unformat_input_t _line_input, *line_input = &_line_input; int i; @@ -324,12 +312,7 @@ show_crypto_async_status_command_fn (vlib_main_t * vm, if (unformat_user (input, unformat_line_input, line_input)) unformat_free (line_input); - vlib_cli_output (vm, "Crypto async dispatch mode: %s", - cm->dispatch_mode == - VNET_CRYPTO_ASYNC_DISPATCH_POLLING ? "POLLING" : - "INTERRUPT"); - - for (i = skip_master; i < tm->n_vlib_mains; i++) + for (i = 0; i < tm->n_vlib_mains; i++) { vlib_node_state_t state = vlib_node_get_state ( vlib_get_main_by_index (i), cm->crypto_node_index); @@ -343,14 +326,12 @@ show_crypto_async_status_command_fn (vlib_main_t * vm, return 0; } -/* *INDENT-OFF* */ VLIB_CLI_COMMAND (show_crypto_async_status_command, static) = { .path = "show crypto async status", .short_help = "show crypto async status", .function = show_crypto_async_status_command_fn, }; -/* *INDENT-ON* */ static clib_error_t * set_crypto_async_handler_command_fn (vlib_main_t * vm, @@ -394,13 +375,11 @@ set_crypto_async_handler_command_fn (vlib_main_t * vm, char *key; u8 *value; - /* *INDENT-OFF* */ hash_foreach_mem (key, value, cm->async_alg_index_by_name, ({ (void) value; rc += vnet_crypto_set_async_handler2 (key, engine); })); - /* *INDENT-ON* */ if (rc) vlib_cli_output (vm, "failed to set crypto engine!"); @@ -426,57 +405,52 @@ done: return error; } -/* *INDENT-OFF* */ VLIB_CLI_COMMAND (set_crypto_async_handler_command, static) = { .path = "set crypto async handler", .short_help = "set crypto async handler type [type2 type3 ...] engine", .function = set_crypto_async_handler_command_fn, }; -/* *INDENT-ON* */ - -static inline void -print_crypto_async_dispatch_warning () -{ - clib_warning ("Switching dispatch mode might not work is some situations."); - clib_warning - ("Use 'show crypto async status' to verify that the nodes' states were set"); - clib_warning ("and if not, set 'crypto async dispatch' mode again."); -} static clib_error_t * -set_crypto_async_dispatch_polling_command_fn (vlib_main_t * vm, - unformat_input_t * input, - vlib_cli_command_t * cmd) +set_crypto_async_dispatch_command_fn (vlib_main_t *vm, unformat_input_t *input, + vlib_cli_command_t *cmd) { - print_crypto_async_dispatch_warning (); - vnet_crypto_set_async_dispatch_mode (VNET_CRYPTO_ASYNC_DISPATCH_POLLING); - return 0; -} + unformat_input_t _line_input, *line_input = &_line_input; + clib_error_t *error = 0; + u8 adaptive = 0; + u8 mode = VLIB_NODE_STATE_INTERRUPT; -static clib_error_t * -set_crypto_async_dispatch_interrupt_command_fn (vlib_main_t * vm, - unformat_input_t * input, - vlib_cli_command_t * cmd) -{ - print_crypto_async_dispatch_warning (); - vnet_crypto_set_async_dispatch_mode (VNET_CRYPTO_ASYNC_DISPATCH_INTERRUPT); - return 0; + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "polling")) + mode = VLIB_NODE_STATE_POLLING; + else if (unformat (line_input, "interrupt")) + mode = VLIB_NODE_STATE_INTERRUPT; + else if (unformat (line_input, "adaptive")) + adaptive = 1; + else + { + error = clib_error_return (0, "invalid params"); + goto done; + } + } + + vnet_crypto_set_async_dispatch (mode, adaptive); +done: + unformat_free (line_input); + return error; } -/* *INDENT-OFF* */ -VLIB_CLI_COMMAND (set_crypto_async_dispatch_polling_command, static) = -{ - .path = "set crypto async dispatch polling", - .short_help = "set crypto async dispatch polling|interrupt", - .function = set_crypto_async_dispatch_polling_command_fn, -}; -VLIB_CLI_COMMAND (set_crypto_async_dispatch_interrupt_command, static) = -{ - .path = "set crypto async dispatch interrupt", - .short_help = "set crypto async dispatch polling|interrupt", - .function = set_crypto_async_dispatch_interrupt_command_fn, +VLIB_CLI_COMMAND (set_crypto_async_dispatch_mode_command, static) = { + .path = "set crypto async dispatch mode", + .short_help = "set crypto async dispatch mode <polling|interrupt|adaptive>", + .function = set_crypto_async_dispatch_command_fn, }; + /* * fd.io coding-style-patch-verification: ON * |