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:
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.
16 #include <vnet/vnet.h>
17 #include <vnet/devices/dpdk/ipsec/ipsec.h>
20 dpdk_ipsec_show_mapping (vlib_main_t * vm, u16 detail_display)
22 dpdk_crypto_main_t *dcm = &dpdk_crypto_main;
23 vlib_thread_main_t *tm = vlib_get_thread_main ();
27 vlib_cli_output (vm, "worker\t%10s\t%15s\tdir\tdev\tqp\n",
30 vlib_cli_output (vm, "worker\tcrypto device id(type)\n");
32 skip_master = vlib_num_workers () > 0;
34 for (i = 0; i < tm->n_vlib_mains; i++)
37 u32 cpu_index = vlib_mains[i]->cpu_index;
38 crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index];
50 crypto_qp_data_t *qpd;
52 s = format (s, "%u\t", cpu_index);
55 vec_foreach (qpd, cwm->qp_data)
57 u32 dev_id = qpd->dev_id;
59 if ((u16) last_cdev != dev_id)
61 struct rte_cryptodev_info cdev_info;
63 rte_cryptodev_info_get (dev_id, &cdev_info);
65 s = format(s, "%u(%s)\t", dev_id, cdev_info.feature_flags &
66 RTE_CRYPTODEV_FF_HW_ACCELERATED ? "HW" : "SW");
71 vlib_cli_output (vm, "%s", s);
75 char cipher_str[15], auth_str[15];
76 struct rte_cryptodev_capabilities cap;
77 crypto_worker_qp_key_t *p_key = (crypto_worker_qp_key_t *) & key;
79 hash_foreach (key, data, cwm->algo_qp_map,
81 cap.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC;
82 cap.sym.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER;
83 cap.sym.cipher.algo = p_key->cipher_algo;
84 check_algo_is_supported (&cap, cipher_str);
85 cap.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC;
86 cap.sym.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH;
87 cap.sym.auth.algo = p_key->auth_algo;
88 check_algo_is_supported (&cap, auth_str);
89 vlib_cli_output (vm, "%u\t%10s\t%15s\t%3s\t%u\t%u\n",
90 vlib_mains[i]->cpu_index, cipher_str, auth_str,
91 p_key->is_outbound ? "out" : "in",
92 cwm->qp_data[data].dev_id,
93 cwm->qp_data[data].qp_id);
100 static clib_error_t *
101 lcore_cryptodev_map_fn (vlib_main_t * vm, unformat_input_t * input,
102 vlib_cli_command_t * cmd)
104 unformat_input_t _line_input, *line_input = &_line_input;
107 if (!unformat_user (input, unformat_line_input, line_input))
110 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
112 if (unformat (line_input, "verbose"))
115 return clib_error_return (0, "parse error: '%U'",
116 format_unformat_error, line_input);
119 unformat_free (line_input);
121 dpdk_ipsec_show_mapping (vm, detail);
127 VLIB_CLI_COMMAND (lcore_cryptodev_map, static) = {
128 .path = "show crypto device mapping",
130 "show cryptodev device mapping <verbose>",
131 .function = lcore_cryptodev_map_fn,
136 * fd.io coding-style-patch-verification: ON
139 * eval: (c-set-style "gnu")