Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 1 | /* |
| 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: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 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. |
| 14 | */ |
| 15 | |
| 16 | #include <stdbool.h> |
| 17 | #include <vlib/vlib.h> |
| 18 | #include <vnet/crypto/crypto.h> |
| 19 | |
| 20 | static clib_error_t * |
| 21 | show_crypto_engines_command_fn (vlib_main_t * vm, |
| 22 | unformat_input_t * input, |
| 23 | vlib_cli_command_t * cmd) |
| 24 | { |
| 25 | unformat_input_t _line_input, *line_input = &_line_input; |
| 26 | vnet_crypto_main_t *cm = &crypto_main; |
| 27 | vnet_crypto_engine_t *p; |
| 28 | |
| 29 | if (unformat_user (input, unformat_line_input, line_input)) |
| 30 | unformat_free (line_input); |
| 31 | |
| 32 | if (vec_len (cm->engines) == 0) |
| 33 | { |
| 34 | vlib_cli_output (vm, "No crypto engines registered"); |
| 35 | return 0; |
| 36 | } |
| 37 | |
| 38 | vlib_cli_output (vm, "%-20s%-8s%s", "Name", "Prio", "Description"); |
| 39 | /* *INDENT-OFF* */ |
| 40 | vec_foreach (p, cm->engines) |
| 41 | { |
| 42 | vlib_cli_output (vm, "%-20s%-8u%s", p->name, p->priority, p->desc); |
| 43 | } |
| 44 | /* *INDENT-ON* */ |
| 45 | return 0; |
| 46 | } |
| 47 | |
| 48 | /* *INDENT-OFF* */ |
| 49 | VLIB_CLI_COMMAND (show_crypto_engines_command, static) = |
| 50 | { |
| 51 | .path = "show crypto engines", |
| 52 | .short_help = "show crypto engines", |
| 53 | .function = show_crypto_engines_command_fn, |
| 54 | }; |
| 55 | |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 56 | static u8 * |
Filip Tehlar | 1307b2e | 2020-02-13 20:50:12 +0000 | [diff] [blame] | 57 | format_vnet_crypto_engine_candidates (u8 * s, va_list * args) |
| 58 | { |
| 59 | vnet_crypto_engine_t *e; |
| 60 | vnet_crypto_main_t *cm = &crypto_main; |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 61 | u32 id = va_arg (*args, u32); |
Filip Tehlar | 1307b2e | 2020-02-13 20:50:12 +0000 | [diff] [blame] | 62 | u32 ei = va_arg (*args, u32); |
| 63 | int is_chained = va_arg (*args, int); |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 64 | int is_async = va_arg (*args, int); |
Filip Tehlar | 1307b2e | 2020-02-13 20:50:12 +0000 | [diff] [blame] | 65 | |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 66 | if (is_async) |
Filip Tehlar | 1307b2e | 2020-02-13 20:50:12 +0000 | [diff] [blame] | 67 | { |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 68 | vec_foreach (e, cm->engines) |
| 69 | { |
Jakub Wysocki | 83b2bb8 | 2021-11-30 10:53:03 +0000 | [diff] [blame] | 70 | if (e->enqueue_handlers[id] && e->dequeue_handler) |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 71 | { |
| 72 | s = format (s, "%U", format_vnet_crypto_engine, e - cm->engines); |
| 73 | if (ei == e - cm->engines) |
| 74 | s = format (s, "%c ", '*'); |
| 75 | else |
| 76 | s = format (s, " "); |
| 77 | } |
| 78 | } |
Filip Tehlar | 1307b2e | 2020-02-13 20:50:12 +0000 | [diff] [blame] | 79 | |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 80 | return s; |
Filip Tehlar | 1307b2e | 2020-02-13 20:50:12 +0000 | [diff] [blame] | 81 | } |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 82 | else |
| 83 | { |
| 84 | vec_foreach (e, cm->engines) |
| 85 | { |
| 86 | void * h = is_chained ? (void *) e->chained_ops_handlers[id] |
| 87 | : (void *) e->ops_handlers[id]; |
| 88 | |
| 89 | if (h) |
| 90 | { |
| 91 | s = format (s, "%U", format_vnet_crypto_engine, e - cm->engines); |
| 92 | if (ei == e - cm->engines) |
| 93 | s = format (s, "%c ", '*'); |
| 94 | else |
| 95 | s = format (s, " "); |
| 96 | } |
| 97 | } |
| 98 | return s; |
| 99 | } |
Filip Tehlar | 1307b2e | 2020-02-13 20:50:12 +0000 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | static u8 * |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 103 | format_vnet_crypto_handlers (u8 * s, va_list * args) |
| 104 | { |
| 105 | vnet_crypto_alg_t alg = va_arg (*args, vnet_crypto_alg_t); |
| 106 | vnet_crypto_main_t *cm = &crypto_main; |
| 107 | vnet_crypto_alg_data_t *d = vec_elt_at_index (cm->algs, alg); |
| 108 | u32 indent = format_get_indent (s); |
| 109 | int i, first = 1; |
| 110 | |
| 111 | for (i = 0; i < VNET_CRYPTO_OP_N_TYPES; i++) |
| 112 | { |
| 113 | vnet_crypto_op_data_t *od; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 114 | vnet_crypto_op_id_t id = d->op_by_type[i]; |
| 115 | |
| 116 | if (id == 0) |
| 117 | continue; |
| 118 | |
Lijian Zhang | b15d796 | 2019-09-27 16:25:35 +0800 | [diff] [blame] | 119 | od = cm->opt_data + id; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 120 | if (first == 0) |
| 121 | s = format (s, "\n%U", format_white_space, indent); |
Filip Tehlar | 1307b2e | 2020-02-13 20:50:12 +0000 | [diff] [blame] | 122 | s = format (s, "%-16U", format_vnet_crypto_op_type, od->type); |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 123 | |
Filip Tehlar | 1307b2e | 2020-02-13 20:50:12 +0000 | [diff] [blame] | 124 | s = format (s, "%-28U", format_vnet_crypto_engine_candidates, id, |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 125 | od->active_engine_index_simple, 0, 0); |
Filip Tehlar | 1307b2e | 2020-02-13 20:50:12 +0000 | [diff] [blame] | 126 | s = format (s, "%U", format_vnet_crypto_engine_candidates, id, |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 127 | od->active_engine_index_chained, 1, 0); |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 128 | first = 0; |
| 129 | } |
| 130 | return s; |
| 131 | } |
| 132 | |
| 133 | |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 134 | static clib_error_t * |
| 135 | show_crypto_handlers_command_fn (vlib_main_t * vm, |
| 136 | unformat_input_t * input, vlib_cli_command_t * cmd) |
| 137 | { |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 138 | unformat_input_t _line_input, *line_input = &_line_input; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 139 | int i; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 140 | |
| 141 | if (unformat_user (input, unformat_line_input, line_input)) |
| 142 | unformat_free (line_input); |
| 143 | |
Filip Tehlar | 1307b2e | 2020-02-13 20:50:12 +0000 | [diff] [blame] | 144 | vlib_cli_output (vm, "%-16s%-16s%-28s%s", "Algo", "Type", "Simple", |
| 145 | "Chained"); |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 146 | |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 147 | for (i = 0; i < VNET_CRYPTO_N_ALGS; i++) |
Benoît Ganne | 84e6658 | 2023-03-10 17:33:03 +0100 | [diff] [blame] | 148 | vlib_cli_output (vm, "%-20U%U", format_vnet_crypto_alg, i, |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 149 | format_vnet_crypto_handlers, i); |
| 150 | |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 151 | return 0; |
| 152 | } |
| 153 | |
| 154 | /* *INDENT-OFF* */ |
| 155 | VLIB_CLI_COMMAND (show_crypto_handlers_command, static) = |
| 156 | { |
| 157 | .path = "show crypto handlers", |
| 158 | .short_help = "show crypto handlers", |
| 159 | .function = show_crypto_handlers_command_fn, |
| 160 | }; |
| 161 | /* *INDENT-ON* */ |
| 162 | |
Filip Tehlar | 1469d54 | 2019-03-25 09:04:41 -0700 | [diff] [blame] | 163 | static clib_error_t * |
| 164 | set_crypto_handler_command_fn (vlib_main_t * vm, |
| 165 | unformat_input_t * input, |
| 166 | vlib_cli_command_t * cmd) |
| 167 | { |
| 168 | unformat_input_t _line_input, *line_input = &_line_input; |
| 169 | vnet_crypto_main_t *cm = &crypto_main; |
| 170 | int rc = 0; |
| 171 | char **args = 0, *s, **arg, *engine = 0; |
| 172 | int all = 0; |
| 173 | clib_error_t *error = 0; |
Filip Tehlar | efcad1a | 2020-02-04 09:36:04 +0000 | [diff] [blame] | 174 | crypto_op_class_type_t oct = CRYPTO_OP_BOTH; |
Filip Tehlar | 1469d54 | 2019-03-25 09:04:41 -0700 | [diff] [blame] | 175 | |
| 176 | if (!unformat_user (input, unformat_line_input, line_input)) |
| 177 | return 0; |
| 178 | |
| 179 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 180 | { |
| 181 | if (unformat (line_input, "all")) |
| 182 | all = 1; |
Filip Tehlar | efcad1a | 2020-02-04 09:36:04 +0000 | [diff] [blame] | 183 | else if (unformat (line_input, "simple")) |
| 184 | oct = CRYPTO_OP_SIMPLE; |
| 185 | else if (unformat (line_input, "chained")) |
| 186 | oct = CRYPTO_OP_CHAINED; |
| 187 | else if (unformat (line_input, "both")) |
| 188 | oct = CRYPTO_OP_BOTH; |
Filip Tehlar | 1469d54 | 2019-03-25 09:04:41 -0700 | [diff] [blame] | 189 | else if (unformat (line_input, "%s", &s)) |
| 190 | vec_add1 (args, s); |
| 191 | else |
| 192 | { |
| 193 | error = clib_error_return (0, "invalid params"); |
| 194 | goto done; |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | if ((vec_len (args) < 2 && !all) || (vec_len (args) == 0 && all)) |
| 199 | { |
| 200 | error = clib_error_return (0, "missing cipher or engine!"); |
| 201 | goto done; |
| 202 | } |
| 203 | |
| 204 | engine = vec_elt_at_index (args, vec_len (args) - 1)[0]; |
| 205 | vec_del1 (args, vec_len (args) - 1); |
| 206 | |
| 207 | if (all) |
| 208 | { |
| 209 | char *key; |
| 210 | u8 *value; |
| 211 | |
| 212 | /* *INDENT-OFF* */ |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 213 | hash_foreach_mem (key, value, cm->alg_index_by_name, |
Filip Tehlar | 1469d54 | 2019-03-25 09:04:41 -0700 | [diff] [blame] | 214 | ({ |
| 215 | (void) value; |
Filip Tehlar | efcad1a | 2020-02-04 09:36:04 +0000 | [diff] [blame] | 216 | rc += vnet_crypto_set_handler2 (key, engine, oct); |
Filip Tehlar | 1469d54 | 2019-03-25 09:04:41 -0700 | [diff] [blame] | 217 | })); |
| 218 | /* *INDENT-ON* */ |
| 219 | |
| 220 | if (rc) |
| 221 | vlib_cli_output (vm, "failed to set crypto engine!"); |
| 222 | } |
| 223 | else |
| 224 | { |
| 225 | vec_foreach (arg, args) |
| 226 | { |
Filip Tehlar | efcad1a | 2020-02-04 09:36:04 +0000 | [diff] [blame] | 227 | rc = vnet_crypto_set_handler2 (arg[0], engine, oct); |
Filip Tehlar | 1469d54 | 2019-03-25 09:04:41 -0700 | [diff] [blame] | 228 | if (rc) |
| 229 | { |
| 230 | vlib_cli_output (vm, "failed to set engine %s for %s!", |
| 231 | engine, arg[0]); |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | done: |
| 237 | vec_free (engine); |
| 238 | vec_foreach (arg, args) vec_free (arg[0]); |
| 239 | vec_free (args); |
| 240 | unformat_free (line_input); |
| 241 | return error; |
| 242 | } |
| 243 | |
| 244 | /* *INDENT-OFF* */ |
| 245 | VLIB_CLI_COMMAND (set_crypto_handler_command, static) = |
| 246 | { |
| 247 | .path = "set crypto handler", |
Filip Tehlar | efcad1a | 2020-02-04 09:36:04 +0000 | [diff] [blame] | 248 | .short_help = "set crypto handler cipher [cipher2 cipher3 ...] engine" |
| 249 | " [simple|chained]", |
Filip Tehlar | 1469d54 | 2019-03-25 09:04:41 -0700 | [diff] [blame] | 250 | .function = set_crypto_handler_command_fn, |
| 251 | }; |
| 252 | /* *INDENT-ON* */ |
| 253 | |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 254 | static u8 * |
| 255 | format_vnet_crypto_async_handlers (u8 * s, va_list * args) |
| 256 | { |
| 257 | vnet_crypto_async_alg_t alg = va_arg (*args, vnet_crypto_async_alg_t); |
| 258 | vnet_crypto_main_t *cm = &crypto_main; |
| 259 | vnet_crypto_async_alg_data_t *d = vec_elt_at_index (cm->async_algs, alg); |
| 260 | u32 indent = format_get_indent (s); |
| 261 | int i, first = 1; |
| 262 | |
| 263 | for (i = 0; i < VNET_CRYPTO_ASYNC_OP_N_TYPES; i++) |
| 264 | { |
| 265 | vnet_crypto_async_op_data_t *od; |
| 266 | vnet_crypto_async_op_id_t id = d->op_by_type[i]; |
| 267 | |
| 268 | if (id == 0) |
| 269 | continue; |
| 270 | |
| 271 | od = cm->async_opt_data + id; |
| 272 | if (first == 0) |
| 273 | s = format (s, "\n%U", format_white_space, indent); |
| 274 | s = format (s, "%-16U", format_vnet_crypto_async_op_type, od->type); |
| 275 | |
| 276 | s = format (s, "%U", format_vnet_crypto_engine_candidates, id, |
| 277 | od->active_engine_index_async, 0, 1); |
| 278 | first = 0; |
| 279 | } |
| 280 | return s; |
| 281 | } |
| 282 | |
| 283 | static clib_error_t * |
| 284 | show_crypto_async_handlers_command_fn (vlib_main_t * vm, |
| 285 | unformat_input_t * input, |
| 286 | vlib_cli_command_t * cmd) |
| 287 | { |
| 288 | unformat_input_t _line_input, *line_input = &_line_input; |
| 289 | int i; |
| 290 | |
| 291 | if (unformat_user (input, unformat_line_input, line_input)) |
| 292 | unformat_free (line_input); |
| 293 | |
| 294 | vlib_cli_output (vm, "%-28s%-16s%s", "Algo", "Type", "Handler"); |
| 295 | |
| 296 | for (i = 0; i < VNET_CRYPTO_N_ASYNC_ALGS; i++) |
| 297 | vlib_cli_output (vm, "%-28U%U", format_vnet_crypto_async_alg, i, |
| 298 | format_vnet_crypto_async_handlers, i); |
| 299 | |
| 300 | return 0; |
| 301 | } |
| 302 | |
| 303 | /* *INDENT-OFF* */ |
| 304 | VLIB_CLI_COMMAND (show_crypto_async_handlers_command, static) = |
| 305 | { |
| 306 | .path = "show crypto async handlers", |
| 307 | .short_help = "show crypto async handlers", |
| 308 | .function = show_crypto_async_handlers_command_fn, |
| 309 | }; |
| 310 | /* *INDENT-ON* */ |
| 311 | |
| 312 | |
| 313 | static clib_error_t * |
PiotrX Kleski | 2284817 | 2020-07-08 14:36:34 +0200 | [diff] [blame] | 314 | show_crypto_async_status_command_fn (vlib_main_t * vm, |
| 315 | unformat_input_t * input, |
| 316 | vlib_cli_command_t * cmd) |
| 317 | { |
| 318 | vnet_crypto_main_t *cm = &crypto_main; |
PiotrX Kleski | 2284817 | 2020-07-08 14:36:34 +0200 | [diff] [blame] | 319 | vlib_thread_main_t *tm = vlib_get_thread_main (); |
| 320 | unformat_input_t _line_input, *line_input = &_line_input; |
| 321 | int i; |
| 322 | |
| 323 | if (unformat_user (input, unformat_line_input, line_input)) |
| 324 | unformat_free (line_input); |
| 325 | |
Xiaoming Jiang | 9a9604b | 2023-03-09 02:03:50 +0000 | [diff] [blame] | 326 | for (i = 0; i < tm->n_vlib_mains; i++) |
PiotrX Kleski | 2284817 | 2020-07-08 14:36:34 +0200 | [diff] [blame] | 327 | { |
Damjan Marion | 6ffb7c6 | 2021-03-26 13:06:13 +0100 | [diff] [blame] | 328 | vlib_node_state_t state = vlib_node_get_state ( |
| 329 | vlib_get_main_by_index (i), cm->crypto_node_index); |
PiotrX Kleski | 2284817 | 2020-07-08 14:36:34 +0200 | [diff] [blame] | 330 | if (state == VLIB_NODE_STATE_POLLING) |
| 331 | vlib_cli_output (vm, "threadId: %-6d POLLING", i); |
| 332 | if (state == VLIB_NODE_STATE_INTERRUPT) |
| 333 | vlib_cli_output (vm, "threadId: %-6d INTERRUPT", i); |
| 334 | if (state == VLIB_NODE_STATE_DISABLED) |
| 335 | vlib_cli_output (vm, "threadId: %-6d DISABLED", i); |
| 336 | } |
| 337 | return 0; |
| 338 | } |
| 339 | |
| 340 | /* *INDENT-OFF* */ |
| 341 | VLIB_CLI_COMMAND (show_crypto_async_status_command, static) = |
| 342 | { |
| 343 | .path = "show crypto async status", |
| 344 | .short_help = "show crypto async status", |
| 345 | .function = show_crypto_async_status_command_fn, |
| 346 | }; |
| 347 | /* *INDENT-ON* */ |
| 348 | |
| 349 | static clib_error_t * |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 350 | set_crypto_async_handler_command_fn (vlib_main_t * vm, |
| 351 | unformat_input_t * input, |
| 352 | vlib_cli_command_t * cmd) |
| 353 | { |
| 354 | unformat_input_t _line_input, *line_input = &_line_input; |
| 355 | vnet_crypto_main_t *cm = &crypto_main; |
| 356 | int rc = 0; |
| 357 | char **args = 0, *s, **arg, *engine = 0; |
| 358 | int all = 0; |
| 359 | clib_error_t *error = 0; |
| 360 | |
| 361 | if (!unformat_user (input, unformat_line_input, line_input)) |
| 362 | return 0; |
| 363 | |
| 364 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 365 | { |
| 366 | if (unformat (line_input, "all")) |
| 367 | all = 1; |
| 368 | else if (unformat (line_input, "%s", &s)) |
| 369 | vec_add1 (args, s); |
| 370 | else |
| 371 | { |
| 372 | error = clib_error_return (0, "invalid params"); |
| 373 | goto done; |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | if ((vec_len (args) < 2 && !all) || (vec_len (args) == 0 && all)) |
| 378 | { |
| 379 | error = clib_error_return (0, "missing cipher or engine!"); |
| 380 | goto done; |
| 381 | } |
| 382 | |
| 383 | engine = vec_elt_at_index (args, vec_len (args) - 1)[0]; |
| 384 | vec_del1 (args, vec_len (args) - 1); |
| 385 | |
| 386 | if (all) |
| 387 | { |
| 388 | char *key; |
| 389 | u8 *value; |
| 390 | |
| 391 | /* *INDENT-OFF* */ |
| 392 | hash_foreach_mem (key, value, cm->async_alg_index_by_name, |
| 393 | ({ |
| 394 | (void) value; |
| 395 | rc += vnet_crypto_set_async_handler2 (key, engine); |
| 396 | })); |
| 397 | /* *INDENT-ON* */ |
| 398 | |
| 399 | if (rc) |
| 400 | vlib_cli_output (vm, "failed to set crypto engine!"); |
| 401 | } |
| 402 | else |
| 403 | { |
| 404 | vec_foreach (arg, args) |
| 405 | { |
| 406 | rc = vnet_crypto_set_async_handler2 (arg[0], engine); |
| 407 | if (rc) |
| 408 | { |
| 409 | vlib_cli_output (vm, "failed to set engine %s for %s!", |
| 410 | engine, arg[0]); |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | done: |
| 416 | vec_free (engine); |
| 417 | vec_foreach (arg, args) vec_free (arg[0]); |
| 418 | vec_free (args); |
| 419 | unformat_free (line_input); |
| 420 | return error; |
| 421 | } |
| 422 | |
| 423 | /* *INDENT-OFF* */ |
| 424 | VLIB_CLI_COMMAND (set_crypto_async_handler_command, static) = |
| 425 | { |
| 426 | .path = "set crypto async handler", |
| 427 | .short_help = "set crypto async handler type [type2 type3 ...] engine", |
| 428 | .function = set_crypto_async_handler_command_fn, |
| 429 | }; |
| 430 | /* *INDENT-ON* */ |
| 431 | |
Niyaz Murshed | 7f050d9 | 2024-02-21 19:54:24 +0000 | [diff] [blame] | 432 | static clib_error_t * |
| 433 | set_crypto_async_dispatch_command_fn (vlib_main_t *vm, unformat_input_t *input, |
| 434 | vlib_cli_command_t *cmd) |
| 435 | { |
| 436 | unformat_input_t _line_input, *line_input = &_line_input; |
| 437 | clib_error_t *error = 0; |
| 438 | u8 adaptive = 0; |
| 439 | u8 mode = VLIB_NODE_STATE_INTERRUPT; |
| 440 | |
| 441 | if (!unformat_user (input, unformat_line_input, line_input)) |
| 442 | return 0; |
| 443 | |
| 444 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 445 | { |
| 446 | if (unformat (line_input, "polling")) |
| 447 | mode = VLIB_NODE_STATE_POLLING; |
| 448 | else if (unformat (line_input, "interrupt")) |
| 449 | mode = VLIB_NODE_STATE_INTERRUPT; |
| 450 | else if (unformat (line_input, "adaptive")) |
| 451 | adaptive = 1; |
| 452 | else |
| 453 | { |
| 454 | error = clib_error_return (0, "invalid params"); |
| 455 | goto done; |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | vnet_crypto_set_async_dispatch (mode, adaptive); |
| 460 | done: |
| 461 | unformat_free (line_input); |
| 462 | return error; |
| 463 | } |
| 464 | |
| 465 | VLIB_CLI_COMMAND (set_crypto_async_dispatch_mode_command, static) = { |
| 466 | .path = "set crypto async dispatch mode", |
| 467 | .short_help = "set crypto async dispatch mode <polling|interrupt|adaptive>", |
| 468 | .function = set_crypto_async_dispatch_command_fn, |
| 469 | }; |
| 470 | |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 471 | /* |
| 472 | * fd.io coding-style-patch-verification: ON |
| 473 | * |
| 474 | * Local Variables: |
| 475 | * eval: (c-set-style "gnu") |
| 476 | * End: |
| 477 | */ |