FD.io VPP  v17.04.2-2-ga8f93f8
Vector Packet Processing
cli.c
Go to the documentation of this file.
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>
17 #include <dpdk/device/dpdk.h>
18 #include <dpdk/ipsec/ipsec.h>
19 
20 static void
22 {
26  u32 i, skip_master;
27 
28  if (!conf->cryptodev)
29  {
30  vlib_cli_output (vm, "DPDK Cryptodev support is disabled\n");
31  return;
32  }
33 
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;
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 *
110  vlib_cli_command_t * cmd)
111 {
112  unformat_input_t _line_input, *line_input = &_line_input;
113  u16 detail = 0;
114  clib_error_t *error = NULL;
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
124  {
125  error = clib_error_return (0, "parse error: '%U'",
126  format_unformat_error, line_input);
127  goto done;
128  }
129  }
130 
131  dpdk_ipsec_show_mapping (vm, detail);
132 
133 done:
134  unformat_free (line_input);
135 
136  return error;
137 }
138 
139 /*?
140  * This command is used to display the DPDK Crypto device data. See
141  * @ref dpdk_crypto_ipsec_doc for more details on initializing the
142  * DPDK Crypto device.
143  *
144  * @cliexpar
145  * Example of displaying the DPDK Crypto device data when disabled:
146  * @cliexstart{show crypto device mapping}
147  * DPDK Cryptodev support is disabled
148  * @cliexend
149  * Example of displaying the DPDK Crypto device data when enabled:
150  * @cliexstart{show crypto device mapping}
151  * worker crypto device id(type)
152  * 1 1(SW)
153  * 2 1(SW)
154  * @cliexend
155  * Example of displaying the DPDK Crypto device data when enabled with verbose:
156  * @cliexstart{show crypto device mapping verbose}
157  * worker cipher auth dir dev qp
158  * 1 AES_CTR AES-XCBC-MAC in 1 0
159  * 1 AES_CTR HMAC-SHA384 in 1 0
160  * 1 AES_CTR HMAC-SHA384 out 1 1
161  * 1 AES_CBC HMAC-SHA512 in 1 0
162  * 1 AES_CBC HMAC-SHA256 in 1 0
163  * 1 AES_CBC AES-XCBC-MAC out 1 1
164  * 1 AES_CTR AES-XCBC-MAC out 1 1
165  * 1 AES_CBC HMAC-SHA256 out 1 1
166  * 1 AES_CTR HMAC-SHA512 out 1 1
167  * 1 AES_CTR HMAC-SHA256 in 1 0
168  * 1 AES_CTR HMAC-SHA1 in 1 0
169  * 1 AES_CBC HMAC-SHA512 out 1 1
170  * 1 AES_CBC HMAC-SHA384 out 1 1
171  * 1 AES_CTR HMAC-SHA1 out 1 1
172  * 1 AES_CTR HMAC-SHA256 out 1 1
173  * 1 AES_CBC HMAC-SHA1 in 1 0
174  * 1 AES_CBC AES-XCBC-MAC in 1 0
175  * 1 AES_CTR HMAC-SHA512 in 1 0
176  * 1 AES_CBC HMAC-SHA1 out 1 1
177  * 1 AES_CBC HMAC-SHA384 in 1 0
178  * 2 AES_CTR AES-XCBC-MAC in 1 2
179  * 2 AES_CTR HMAC-SHA384 in 1 2
180  * 2 AES_CTR HMAC-SHA384 out 1 3
181  * 2 AES_CBC HMAC-SHA512 in 1 2
182  * 2 AES_CBC HMAC-SHA256 in 1 2
183  * 2 AES_CBC AES-XCBC-MAC out 1 3
184  * 2 AES_CTR AES-XCBC-MAC out 1 3
185  * 2 AES_CBC HMAC-SHA256 out 1 3
186  * 2 AES_CTR HMAC-SHA512 out 1 3
187  * 2 AES_CTR HMAC-SHA256 in 1 2
188  * 2 AES_CTR HMAC-SHA1 in 1 2
189  * 2 AES_CBC HMAC-SHA512 out 1 3
190  * 2 AES_CBC HMAC-SHA384 out 1 3
191  * 2 AES_CTR HMAC-SHA1 out 1 3
192  * 2 AES_CTR HMAC-SHA256 out 1 3
193  * 2 AES_CBC HMAC-SHA1 in 1 2
194  * 2 AES_CBC AES-XCBC-MAC in 1 2
195  * 2 AES_CTR HMAC-SHA512 in 1 2
196  * 2 AES_CBC HMAC-SHA1 out 1 3
197  * 2 AES_CBC HMAC-SHA384 in 1 2
198  * @cliexend
199 ?*/
200 /* *INDENT-OFF* */
201 VLIB_CLI_COMMAND (lcore_cryptodev_map, static) = {
202  .path = "show crypto device mapping",
203  .short_help =
204  "show cryptodev device mapping [verbose]",
205  .function = lcore_cryptodev_map_fn,
206 };
207 /* *INDENT-ON* */
208 
209 /*
210  * fd.io coding-style-patch-verification: ON
211  *
212  * Local Variables:
213  * eval: (c-set-style "gnu")
214  * End:
215  */
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
#define NULL
Definition: clib.h:55
static void dpdk_ipsec_show_mapping(vlib_main_t *vm, u16 detail_display)
Definition: cli.c:21
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:982
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
vlib_main_t ** vlib_mains
Definition: buffer.c:285
dpdk_crypto_main_t dpdk_crypto_main
Definition: ipsec.h:88
uword * algo_qp_map
Definition: ipsec.h:79
dpdk_config_main_t dpdk_config_main
Definition: dpdk.h:349
int i32
Definition: types.h:81
#define hash_foreach(key_var, value_var, h, body)
Definition: hash.h:418
#define clib_error_return(e, args...)
Definition: error.h:111
u32 cpu_index
Definition: main.h:159
unformat_function_t unformat_line_input
Definition: format.h:281
struct _unformat_input_t unformat_input_t
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
vlib_main_t * vm
Definition: buffer.c:276
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
unsigned int u32
Definition: types.h:88
crypto_worker_main_t * workers_main
Definition: ipsec.h:85
crypto_qp_data_t * qp_data
Definition: ipsec.h:78
u64 uword
Definition: types.h:112
unsigned short u16
Definition: types.h:57
unsigned char u8
Definition: types.h:56
static void unformat_free(unformat_input_t *i)
Definition: format.h:161
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:32
static u32 vlib_num_workers()
Definition: threads.h:345
#define vec_foreach(var, vec)
Vector iterator.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:577
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:971
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
static clib_error_t * lcore_cryptodev_map_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:109