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 <dpdk/device/dpdk.h>
18 #include <dpdk/ipsec/ipsec.h>
21 dpdk_ipsec_show_mapping (vlib_main_t * vm, u16 detail_display)
23 dpdk_crypto_main_t *dcm = &dpdk_crypto_main;
24 vlib_thread_main_t *tm = vlib_get_thread_main ();
29 vlib_cli_output (vm, "DPDK Cryptodev support is disabled\n");
34 vlib_cli_output (vm, "worker\t%10s\t%15s\tdir\tdev\tqp\n",
37 vlib_cli_output (vm, "worker\tcrypto device id(type)\n");
39 skip_master = vlib_num_workers () > 0;
41 for (i = 0; i < tm->n_vlib_mains; i++)
44 u32 thread_index = vlib_mains[i]->thread_index;
45 crypto_worker_main_t *cwm = &dcm->workers_main[thread_index];
57 crypto_qp_data_t *qpd;
59 s = format (s, "%u\t", thread_index);
62 vec_foreach (qpd, cwm->qp_data)
64 u32 dev_id = qpd->dev_id;
66 if ((u16) last_cdev != dev_id)
68 struct rte_cryptodev_info cdev_info;
70 rte_cryptodev_info_get (dev_id, &cdev_info);
72 s = format(s, "%u(%s)\t", dev_id, cdev_info.feature_flags &
73 RTE_CRYPTODEV_FF_HW_ACCELERATED ? "HW" : "SW");
78 vlib_cli_output (vm, "%s", s);
82 char cipher_str[15], auth_str[15];
83 struct rte_cryptodev_capabilities cap;
84 crypto_worker_qp_key_t *p_key = (crypto_worker_qp_key_t *) & key;
86 hash_foreach (key, data, cwm->algo_qp_map,
88 cap.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC;
89 cap.sym.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER;
90 cap.sym.cipher.algo = p_key->cipher_algo;
91 check_algo_is_supported (&cap, cipher_str);
92 cap.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC;
93 cap.sym.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH;
94 cap.sym.auth.algo = p_key->auth_algo;
95 check_algo_is_supported (&cap, auth_str);
96 vlib_cli_output (vm, "%u\t%10s\t%15s\t%3s\t%u\t%u\n",
97 vlib_mains[i]->thread_index, cipher_str, auth_str,
98 p_key->is_outbound ? "out" : "in",
99 cwm->qp_data[data].dev_id,
100 cwm->qp_data[data].qp_id);
107 static clib_error_t *
108 lcore_cryptodev_map_fn (vlib_main_t * vm, unformat_input_t * input,
109 vlib_cli_command_t * cmd)
111 unformat_input_t _line_input, *line_input = &_line_input;
113 clib_error_t *error = NULL;
115 if (!unformat_user (input, unformat_line_input, line_input))
118 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
120 if (unformat (line_input, "verbose"))
124 error = clib_error_return (0, "parse error: '%U'",
125 format_unformat_error, line_input);
130 dpdk_ipsec_show_mapping (vm, detail);
133 unformat_free (line_input);
139 * This command is used to display the DPDK Crypto device data. See
140 * @ref dpdk_crypto_ipsec_doc for more details on initializing the
141 * DPDK Crypto device.
144 * Example of displaying the DPDK Crypto device data when disabled:
145 * @cliexstart{show crypto device mapping}
146 * DPDK Cryptodev support is disabled
148 * Example of displaying the DPDK Crypto device data when enabled:
149 * @cliexstart{show crypto device mapping}
150 * worker crypto device id(type)
154 * Example of displaying the DPDK Crypto device data when enabled with verbose:
155 * @cliexstart{show crypto device mapping verbose}
156 * worker cipher auth dir dev qp
157 * 1 AES_CTR AES-XCBC-MAC in 1 0
158 * 1 AES_CTR HMAC-SHA384 in 1 0
159 * 1 AES_CTR HMAC-SHA384 out 1 1
160 * 1 AES_CBC HMAC-SHA512 in 1 0
161 * 1 AES_CBC HMAC-SHA256 in 1 0
162 * 1 AES_CBC AES-XCBC-MAC out 1 1
163 * 1 AES_CTR AES-XCBC-MAC out 1 1
164 * 1 AES_CBC HMAC-SHA256 out 1 1
165 * 1 AES_CTR HMAC-SHA512 out 1 1
166 * 1 AES_CTR HMAC-SHA256 in 1 0
167 * 1 AES_CTR HMAC-SHA1 in 1 0
168 * 1 AES_CBC HMAC-SHA512 out 1 1
169 * 1 AES_CBC HMAC-SHA384 out 1 1
170 * 1 AES_CTR HMAC-SHA1 out 1 1
171 * 1 AES_CTR HMAC-SHA256 out 1 1
172 * 1 AES_CBC HMAC-SHA1 in 1 0
173 * 1 AES_CBC AES-XCBC-MAC in 1 0
174 * 1 AES_CTR HMAC-SHA512 in 1 0
175 * 1 AES_CBC HMAC-SHA1 out 1 1
176 * 1 AES_CBC HMAC-SHA384 in 1 0
177 * 2 AES_CTR AES-XCBC-MAC in 1 2
178 * 2 AES_CTR HMAC-SHA384 in 1 2
179 * 2 AES_CTR HMAC-SHA384 out 1 3
180 * 2 AES_CBC HMAC-SHA512 in 1 2
181 * 2 AES_CBC HMAC-SHA256 in 1 2
182 * 2 AES_CBC AES-XCBC-MAC out 1 3
183 * 2 AES_CTR AES-XCBC-MAC out 1 3
184 * 2 AES_CBC HMAC-SHA256 out 1 3
185 * 2 AES_CTR HMAC-SHA512 out 1 3
186 * 2 AES_CTR HMAC-SHA256 in 1 2
187 * 2 AES_CTR HMAC-SHA1 in 1 2
188 * 2 AES_CBC HMAC-SHA512 out 1 3
189 * 2 AES_CBC HMAC-SHA384 out 1 3
190 * 2 AES_CTR HMAC-SHA1 out 1 3
191 * 2 AES_CTR HMAC-SHA256 out 1 3
192 * 2 AES_CBC HMAC-SHA1 in 1 2
193 * 2 AES_CBC AES-XCBC-MAC in 1 2
194 * 2 AES_CTR HMAC-SHA512 in 1 2
195 * 2 AES_CBC HMAC-SHA1 out 1 3
196 * 2 AES_CBC HMAC-SHA384 in 1 2
200 VLIB_CLI_COMMAND (lcore_cryptodev_map, static) = {
201 .path = "show crypto device mapping",
203 "show cryptodev device mapping [verbose]",
204 .function = lcore_cryptodev_map_fn,
209 * fd.io coding-style-patch-verification: ON
212 * eval: (c-set-style "gnu")