Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 Intel 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 <vnet/vnet.h> |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 17 | #include <vnet/devices/dpdk/dpdk.h> |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 18 | #include <vnet/devices/dpdk/ipsec/ipsec.h> |
| 19 | |
| 20 | static void |
| 21 | dpdk_ipsec_show_mapping (vlib_main_t * vm, u16 detail_display) |
| 22 | { |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 23 | dpdk_config_main_t *conf = &dpdk_config_main; |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 24 | dpdk_crypto_main_t *dcm = &dpdk_crypto_main; |
| 25 | vlib_thread_main_t *tm = vlib_get_thread_main (); |
| 26 | u32 i, skip_master; |
| 27 | |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 28 | if (!conf->cryptodev) |
| 29 | { |
| 30 | vlib_cli_output (vm, "DPDK Cryptodev support is disabled\n"); |
| 31 | return; |
| 32 | } |
| 33 | |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 34 | if (detail_display) |
| 35 | vlib_cli_output (vm, "worker\t%10s\t%15s\tdir\tdev\tqp\n", |
| 36 | "cipher", "auth"); |
| 37 | else |
| 38 | vlib_cli_output (vm, "worker\tcrypto device id(type)\n"); |
| 39 | |
| 40 | skip_master = vlib_num_workers () > 0; |
| 41 | |
| 42 | for (i = 0; i < tm->n_vlib_mains; i++) |
| 43 | { |
| 44 | uword key, data; |
| 45 | u32 cpu_index = vlib_mains[i]->cpu_index; |
| 46 | crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index]; |
| 47 | u8 *s = 0; |
| 48 | |
| 49 | if (skip_master) |
| 50 | { |
| 51 | skip_master = 0; |
| 52 | continue; |
| 53 | } |
| 54 | |
| 55 | if (!detail_display) |
| 56 | { |
| 57 | i32 last_cdev = -1; |
| 58 | crypto_qp_data_t *qpd; |
| 59 | |
| 60 | s = format (s, "%u\t", cpu_index); |
| 61 | |
| 62 | /* *INDENT-OFF* */ |
| 63 | vec_foreach (qpd, cwm->qp_data) |
| 64 | { |
| 65 | u32 dev_id = qpd->dev_id; |
| 66 | |
| 67 | if ((u16) last_cdev != dev_id) |
| 68 | { |
| 69 | struct rte_cryptodev_info cdev_info; |
| 70 | |
| 71 | rte_cryptodev_info_get (dev_id, &cdev_info); |
| 72 | |
| 73 | s = format(s, "%u(%s)\t", dev_id, cdev_info.feature_flags & |
| 74 | RTE_CRYPTODEV_FF_HW_ACCELERATED ? "HW" : "SW"); |
| 75 | } |
| 76 | last_cdev = dev_id; |
| 77 | } |
| 78 | /* *INDENT-ON* */ |
| 79 | vlib_cli_output (vm, "%s", s); |
| 80 | } |
| 81 | else |
| 82 | { |
| 83 | char cipher_str[15], auth_str[15]; |
| 84 | struct rte_cryptodev_capabilities cap; |
| 85 | crypto_worker_qp_key_t *p_key = (crypto_worker_qp_key_t *) & key; |
| 86 | /* *INDENT-OFF* */ |
| 87 | hash_foreach (key, data, cwm->algo_qp_map, |
| 88 | ({ |
| 89 | cap.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC; |
| 90 | cap.sym.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER; |
| 91 | cap.sym.cipher.algo = p_key->cipher_algo; |
| 92 | check_algo_is_supported (&cap, cipher_str); |
| 93 | cap.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC; |
| 94 | cap.sym.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH; |
| 95 | cap.sym.auth.algo = p_key->auth_algo; |
| 96 | check_algo_is_supported (&cap, auth_str); |
| 97 | vlib_cli_output (vm, "%u\t%10s\t%15s\t%3s\t%u\t%u\n", |
| 98 | vlib_mains[i]->cpu_index, cipher_str, auth_str, |
| 99 | p_key->is_outbound ? "out" : "in", |
| 100 | cwm->qp_data[data].dev_id, |
| 101 | cwm->qp_data[data].qp_id); |
| 102 | })); |
| 103 | /* *INDENT-ON* */ |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | static clib_error_t * |
| 109 | lcore_cryptodev_map_fn (vlib_main_t * vm, unformat_input_t * input, |
| 110 | vlib_cli_command_t * cmd) |
| 111 | { |
| 112 | unformat_input_t _line_input, *line_input = &_line_input; |
| 113 | u16 detail = 0; |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame^] | 114 | clib_error_t *error = NULL; |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 115 | |
| 116 | if (!unformat_user (input, unformat_line_input, line_input)) |
| 117 | return 0; |
| 118 | |
| 119 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 120 | { |
| 121 | if (unformat (line_input, "verbose")) |
| 122 | detail = 1; |
| 123 | else |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame^] | 124 | { |
| 125 | error = clib_error_return (0, "parse error: '%U'", |
| 126 | format_unformat_error, line_input); |
| 127 | goto done; |
| 128 | } |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 129 | } |
| 130 | |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 131 | dpdk_ipsec_show_mapping (vm, detail); |
| 132 | |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame^] | 133 | done: |
| 134 | unformat_free (line_input); |
| 135 | |
| 136 | return error; |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | /* *INDENT-OFF* */ |
| 140 | VLIB_CLI_COMMAND (lcore_cryptodev_map, static) = { |
| 141 | .path = "show crypto device mapping", |
| 142 | .short_help = |
| 143 | "show cryptodev device mapping <verbose>", |
| 144 | .function = lcore_cryptodev_map_fn, |
| 145 | }; |
| 146 | /* *INDENT-ON* */ |
| 147 | |
| 148 | /* |
| 149 | * fd.io coding-style-patch-verification: ON |
| 150 | * |
| 151 | * Local Variables: |
| 152 | * eval: (c-set-style "gnu") |
| 153 | * End: |
| 154 | */ |