FD.io VPP  v17.01.1-3-gc6833f8
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>
18 
19 static void
20 dpdk_ipsec_show_mapping (vlib_main_t * vm, u16 detail_display)
21 {
24  u32 i, skip_master;
25 
26  if (detail_display)
27  vlib_cli_output (vm, "worker\t%10s\t%15s\tdir\tdev\tqp\n",
28  "cipher", "auth");
29  else
30  vlib_cli_output (vm, "worker\tcrypto device id(type)\n");
31 
32  skip_master = vlib_num_workers () > 0;
33 
34  for (i = 0; i < tm->n_vlib_mains; i++)
35  {
36  uword key, data;
37  u32 cpu_index = vlib_mains[i]->cpu_index;
38  crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index];
39  u8 *s = 0;
40 
41  if (skip_master)
42  {
43  skip_master = 0;
44  continue;
45  }
46 
47  if (!detail_display)
48  {
49  i32 last_cdev = -1;
50  crypto_qp_data_t *qpd;
51 
52  s = format (s, "%u\t", cpu_index);
53 
54  /* *INDENT-OFF* */
55  vec_foreach (qpd, cwm->qp_data)
56  {
57  u32 dev_id = qpd->dev_id;
58 
59  if ((u16) last_cdev != dev_id)
60  {
61  struct rte_cryptodev_info cdev_info;
62 
63  rte_cryptodev_info_get (dev_id, &cdev_info);
64 
65  s = format(s, "%u(%s)\t", dev_id, cdev_info.feature_flags &
66  RTE_CRYPTODEV_FF_HW_ACCELERATED ? "HW" : "SW");
67  }
68  last_cdev = dev_id;
69  }
70  /* *INDENT-ON* */
71  vlib_cli_output (vm, "%s", s);
72  }
73  else
74  {
75  char cipher_str[15], auth_str[15];
76  struct rte_cryptodev_capabilities cap;
78  /* *INDENT-OFF* */
79  hash_foreach (key, data, cwm->algo_qp_map,
80  ({
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);
94  }));
95  /* *INDENT-ON* */
96  }
97  }
98 }
99 
100 static clib_error_t *
102  vlib_cli_command_t * cmd)
103 {
104  unformat_input_t _line_input, *line_input = &_line_input;
105  u16 detail = 0;
106 
107  if (!unformat_user (input, unformat_line_input, line_input))
108  return 0;
109 
110  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
111  {
112  if (unformat (line_input, "verbose"))
113  detail = 1;
114  else
115  return clib_error_return (0, "parse error: '%U'",
116  format_unformat_error, line_input);
117  }
118 
119  unformat_free (line_input);
120 
121  dpdk_ipsec_show_mapping (vm, detail);
122 
123  return 0;
124 }
125 
126 /* *INDENT-OFF* */
127 VLIB_CLI_COMMAND (lcore_cryptodev_map, static) = {
128  .path = "show crypto device mapping",
129  .short_help =
130  "show cryptodev device mapping <verbose>",
131  .function = lcore_cryptodev_map_fn,
132 };
133 /* *INDENT-ON* */
134 
135 /*
136  * fd.io coding-style-patch-verification: ON
137  *
138  * Local Variables:
139  * eval: (c-set-style "gnu")
140  * End:
141  */
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
uword unformat(unformat_input_t *i, char *fmt,...)
Definition: unformat.c:966
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
uword * algo_qp_map
Definition: ipsec.h:78
int i32
Definition: types.h:81
#define hash_foreach(key_var, value_var, h, body)
Definition: hash.h:418
static clib_error_t * lcore_cryptodev_map_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:101
static void unformat_free(unformat_input_t *i)
Definition: format.h:161
u32 cpu_index
Definition: main.h:159
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:977
dpdk_crypto_main_t dpdk_crypto_main
Definition: ipsec.h:87
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:576
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:32
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
unsigned int u32
Definition: types.h:88
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
crypto_worker_main_t * workers_main
Definition: ipsec.h:84
crypto_qp_data_t * qp_data
Definition: ipsec.h:77
u64 uword
Definition: types.h:112
unsigned short u16
Definition: types.h:57
unsigned char u8
Definition: types.h:56
vlib_main_t ** vlib_mains
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
static u32 vlib_num_workers()
Definition: threads.h:340
#define vec_foreach(var, vec)
Vector iterator.
#define clib_error_return(e, args...)
Definition: error.h:111
struct _unformat_input_t unformat_input_t
unformat_function_t unformat_line_input
Definition: format.h:281
static void dpdk_ipsec_show_mapping(vlib_main_t *vm, u16 detail_display)
Definition: cli.c:20