FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
main.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 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 <vlib/vlib.h>
17 #include <vnet/plugin/plugin.h>
18 #include <vpp/app/version.h>
19 
20 #include "crypto_sw_scheduler.h"
21 
22 int
24 {
28  u32 count = 0, i = vlib_num_workers () > 0;
29 
30  if (worker_idx >= vlib_num_workers ())
31  {
32  return VNET_API_ERROR_INVALID_VALUE;
33  }
34 
35  for (; i < tm->n_vlib_mains; i++)
36  {
37  ptd = cm->per_thread_data + i;
38  count += ptd->self_crypto_enabled;
39  }
40 
41  if (enabled || count > 1)
42  {
43  cm->per_thread_data[vlib_get_worker_thread_index
44  (worker_idx)].self_crypto_enabled = enabled;
45  }
46  else /* cannot disable all crypto workers */
47  {
48  return VNET_API_ERROR_INVALID_VALUE_2;
49  }
50  return 0;
51 }
52 
53 static void
56 {
59 
60  vec_validate (cm->keys, idx);
61 
62  if (key->type == VNET_CRYPTO_KEY_TYPE_LINK)
63  {
64  if (kop == VNET_CRYPTO_KEY_OP_DEL)
65  {
66  cm->keys[idx].index_crypto = UINT32_MAX;
67  cm->keys[idx].index_integ = UINT32_MAX;
68  }
69  else
70  {
71  cm->keys[idx] = *key;
72  }
73  }
74 }
75 
76 static int
79 {
82  = vec_elt_at_index (cm->per_thread_data, vm->thread_index);
84  u64 head = q->head;
85 
86  if (q->jobs[head & CRYPTO_SW_SCHEDULER_QUEUE_MASK])
87  {
88  u32 n_elts = frame->n_elts, i;
89  for (i = 0; i < n_elts; i++)
90  frame->elts[i].status = VNET_CRYPTO_OP_STATUS_FAIL_ENGINE_ERR;
91  return -1;
92  }
94  head += 1;
96  q->head = head;
97  return 0;
98 }
99 
102 {
104  u32 i;
105  u32 tail = q->tail;
106  u32 head = q->head;
107 
108  for (i = tail; i < head; i++)
109  {
111  if (!f)
112  continue;
116  {
117  return f;
118  }
119  }
120  return NULL;
121 }
122 
125 {
130  {
131  u32 tail = q->tail;
133  q->tail++;
135  q->jobs[tail & CRYPTO_SW_SCHEDULER_QUEUE_MASK] = 0;
136  }
137  return f;
138 }
139 
144  u32 len)
145 {
147  u32 n_chunks;
148 
149  /*
150  * offset is relative to b->data (can be negative if we stay in pre_data
151  * area). Make sure it does not go beyond the 1st buffer.
152  */
155 
156  op->chunk_index = vec_len (ptd->chunks);
157 
158  vec_add2 (ptd->chunks, ch, 1);
159  ch->src = ch->dst = b->data + offset;
161  len -= ch->len;
162  n_chunks = 1;
163 
164  while (len && b->flags & VLIB_BUFFER_NEXT_PRESENT)
165  {
167  vec_add2 (ptd->chunks, ch, 1);
168  ch->src = ch->dst = vlib_buffer_get_current (b);
169  ch->len = clib_min (b->current_length, len);
170  len -= ch->len;
171  n_chunks++;
172  }
173 
174  if (len)
175  {
176  /* Some async crypto users can use buffers in creative ways, let's allow
177  * some flexibility here...
178  * Current example is ESP decrypt with ESN in async mode: it will stash
179  * ESN at the end of the last buffer (if it can) because it must be part
180  * of the integrity check but it will not update the buffer length.
181  * Fixup the last operation chunk length if we have room.
182  */
185  ch->len += len;
186  }
187 
188  op->n_chunks = n_chunks;
189 }
190 
195  u32 index, u32 bi,
196  vnet_crypto_op_id_t op_id, u16 aad_len,
197  u8 tag_len)
198 {
200  vnet_crypto_op_t *op = 0;
201 
203  {
204  vec_add2 (ptd->chained_crypto_ops, op, 1);
206  fe->crypto_total_length);
207  }
208  else
209  {
210  vec_add2 (ptd->crypto_ops, op, 1);
211  op->src = op->dst = b->data + fe->crypto_start_offset;
212  op->len = fe->crypto_total_length;
213  }
214 
215  op->op = op_id;
216  op->tag = fe->tag;
217  op->flags = fe->flags;
218  op->key_index = fe->key_index;
219  op->iv = fe->iv;
220  op->aad = fe->aad;
221  op->aad_len = aad_len;
222  op->tag_len = tag_len;
223  op->user_data = index;
224 }
225 
229  * ptd, vnet_crypto_key_t * key,
231  u32 index, u32 bi,
232  vnet_crypto_op_id_t crypto_op_id,
233  vnet_crypto_op_id_t integ_op_id,
234  u32 digest_len, u8 is_enc)
235 {
237  vnet_crypto_op_t *crypto_op = 0, *integ_op = 0;
238 
240  {
241  vec_add2 (ptd->chained_crypto_ops, crypto_op, 1);
242  vec_add2 (ptd->chained_integ_ops, integ_op, 1);
243  cryptodev_sw_scheduler_sgl (vm, ptd, b, crypto_op,
245  fe->crypto_total_length);
246  cryptodev_sw_scheduler_sgl (vm, ptd, b, integ_op,
247  fe->integ_start_offset,
248  fe->crypto_total_length +
249  fe->integ_length_adj);
250  }
251  else
252  {
253  vec_add2 (ptd->crypto_ops, crypto_op, 1);
254  vec_add2 (ptd->integ_ops, integ_op, 1);
255  crypto_op->src = crypto_op->dst = b->data + fe->crypto_start_offset;
256  crypto_op->len = fe->crypto_total_length;
257  integ_op->src = integ_op->dst = b->data + fe->integ_start_offset;
258  integ_op->len = fe->crypto_total_length + fe->integ_length_adj;
259  }
260 
261  crypto_op->op = crypto_op_id;
262  crypto_op->iv = fe->iv;
263  crypto_op->key_index = key->index_crypto;
264  crypto_op->user_data = 0;
265  crypto_op->flags = fe->flags & ~VNET_CRYPTO_OP_FLAG_HMAC_CHECK;
266  integ_op->op = integ_op_id;
267  integ_op->digest = fe->digest;
268  integ_op->digest_len = digest_len;
269  integ_op->key_index = key->index_integ;
270  integ_op->flags = fe->flags & ~VNET_CRYPTO_OP_FLAG_INIT_IV;
271  crypto_op->user_data = integ_op->user_data = index;
272 }
273 
276  vnet_crypto_op_t * ops, u8 * state)
277 {
278  u32 n_fail, n_ops = vec_len (ops);
279  vnet_crypto_op_t *op = ops;
280 
281  if (n_ops == 0)
282  return;
283 
284  n_fail = n_ops - vnet_crypto_process_ops (vm, op, n_ops);
285 
286  while (n_fail)
287  {
288  ASSERT (op - ops < n_ops);
289 
290  if (op->status != VNET_CRYPTO_OP_STATUS_COMPLETED)
291  {
292  f->elts[op->user_data].status = op->status;
294  n_fail--;
295  }
296  op++;
297  }
298 }
299 
303  u8 * state)
304 {
305  u32 n_fail, n_ops = vec_len (ops);
306  vnet_crypto_op_t *op = ops;
307 
308  if (n_ops == 0)
309  return;
310 
311  n_fail = n_ops - vnet_crypto_process_chained_ops (vm, op, chunks, n_ops);
312 
313  while (n_fail)
314  {
315  ASSERT (op - ops < n_ops);
316 
317  if (op->status != VNET_CRYPTO_OP_STATUS_COMPLETED)
318  {
319  f->elts[op->user_data].status = op->status;
321  n_fail--;
322  }
323  op++;
324  }
325 }
326 
329  vnet_crypto_async_op_id_t async_op_id,
330  vnet_crypto_op_id_t sync_op_id, u8 tag_len,
331  u8 aad_len, u32 * nb_elts_processed,
332  u32 * enqueue_thread_idx)
333 {
339  u32 *bi;
340  u32 n_elts;
341  int i = 0;
343 
344  if (cm->per_thread_data[vm->thread_index].self_crypto_enabled)
345  {
346  /* *INDENT-OFF* */
347  vec_foreach_index (i, cm->per_thread_data)
348  {
349  ptd = cm->per_thread_data + i;
350  q = ptd->queues[async_op_id];
352  if (f)
353  break;
354  }
355  /* *INDENT-ON* */
356  }
357 
358  ptd = cm->per_thread_data + vm->thread_index;
359 
360  if (f)
361  {
362  *nb_elts_processed = n_elts = f->n_elts;
363  fe = f->elts;
364  bi = f->buffer_indices;
365 
368  vec_reset_length (ptd->chunks);
369 
370  while (n_elts--)
371  {
372  if (n_elts > 1)
373  clib_prefetch_load (fe + 1);
374 
375  crypto_sw_scheduler_convert_aead (vm, ptd, fe, fe - f->elts, bi[0],
376  sync_op_id, aad_len, tag_len);
377  bi++;
378  fe++;
379  }
380 
381  process_ops (vm, f, ptd->crypto_ops, &state);
383  &state);
384  f->state = state;
385  *enqueue_thread_idx = f->enqueue_thread_index;
386  }
387 
388  return crypto_sw_scheduler_get_completed_frame (ptd->queues[async_op_id]);
389 }
390 
393  vnet_crypto_async_op_id_t async_op_id,
394  vnet_crypto_op_id_t sync_crypto_op_id,
395  vnet_crypto_op_id_t sync_integ_op_id,
396  u16 digest_len, u8 is_enc,
397  u32 * nb_elts_processed,
398  u32 * enqueue_thread_idx)
399 {
405  u32 *bi;
406  u32 n_elts;
407  int i = 0;
409 
410  if (cm->per_thread_data[vm->thread_index].self_crypto_enabled)
411  {
412  /* *INDENT-OFF* */
413  vec_foreach_index (i, cm->per_thread_data)
414  {
415  ptd = cm->per_thread_data + i;
416  q = ptd->queues[async_op_id];
418  if (f)
419  break;
420  }
421  /* *INDENT-ON* */
422  }
423 
424  ptd = cm->per_thread_data + vm->thread_index;
425 
426  if (f)
427  {
432  vec_reset_length (ptd->chunks);
433 
434  *nb_elts_processed = n_elts = f->n_elts;
435  fe = f->elts;
436  bi = f->buffer_indices;
437 
438  while (n_elts--)
439  {
440  if (n_elts > 1)
441  clib_prefetch_load (fe + 1);
442 
444  cm->keys + fe->key_index,
445  fe, fe - f->elts, bi[0],
446  sync_crypto_op_id,
447  sync_integ_op_id,
448  digest_len, is_enc);
449  bi++;
450  fe++;
451  }
452 
453  if (is_enc)
454  {
455  process_ops (vm, f, ptd->crypto_ops, &state);
457  &state);
458  process_ops (vm, f, ptd->integ_ops, &state);
460  &state);
461  }
462  else
463  {
464  process_ops (vm, f, ptd->integ_ops, &state);
466  &state);
467  process_ops (vm, f, ptd->crypto_ops, &state);
469  &state);
470  }
471 
472  f->state = state;
473  *enqueue_thread_idx = f->enqueue_thread_index;
474  }
475 
476  return crypto_sw_scheduler_get_completed_frame (ptd->queues[async_op_id]);
477 }
478 
479 static clib_error_t *
481  vlib_cli_command_t * cmd)
482 {
483  unformat_input_t _line_input, *line_input = &_line_input;
484  u32 worker_index;
485  u8 crypto_enable;
486  int rv;
487 
488  /* Get a line of input. */
489  if (!unformat_user (input, unformat_line_input, line_input))
490  return 0;
491 
492  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
493  {
494  if (unformat (line_input, "worker %u", &worker_index))
495  {
496  if (unformat (line_input, "crypto"))
497  {
498  if (unformat (line_input, "on"))
499  crypto_enable = 1;
500  else if (unformat (line_input, "off"))
501  crypto_enable = 0;
502  else
503  return (clib_error_return (0, "unknown input '%U'",
505  line_input));
506  }
507  else
508  return (clib_error_return (0, "unknown input '%U'",
509  format_unformat_error, line_input));
510  }
511  else
512  return (clib_error_return (0, "unknown input '%U'",
513  format_unformat_error, line_input));
514  }
515 
516  rv = crypto_sw_scheduler_set_worker_crypto (worker_index, crypto_enable);
517  if (rv == VNET_API_ERROR_INVALID_VALUE)
518  {
519  return (clib_error_return (0, "invalid worker idx: %d", worker_index));
520  }
521  else if (rv == VNET_API_ERROR_INVALID_VALUE_2)
522  {
523  return (clib_error_return (0, "cannot disable all crypto workers"));
524  }
525  return 0;
526 }
527 
528 /*?
529  * This command sets if worker will do crypto processing.
530  *
531  * @cliexpar
532  * Example of how to set worker crypto processing off:
533  * @cliexstart{set sw_scheduler worker 0 crypto off}
534  * @cliexend
535  ?*/
536 /* *INDENT-OFF* */
538  .path = "set sw_scheduler",
539  .short_help = "set sw_scheduler worker <idx> crypto <on|off>",
540  .function = sw_scheduler_set_worker_crypto,
541  .is_mp_safe = 1,
542 };
543 /* *INDENT-ON* */
544 
545 static clib_error_t *
547  vlib_cli_command_t * cmd)
548 {
550  u32 i;
551 
552  vlib_cli_output (vm, "%-7s%-20s%-8s", "ID", "Name", "Crypto");
553  for (i = 1; i < vlib_thread_main.n_vlib_mains; i++)
554  {
555  vlib_cli_output (vm, "%-7d%-20s%-8s", vlib_get_worker_index (i),
557  cm->
558  per_thread_data[i].self_crypto_enabled ? "on" : "off");
559  }
560 
561  return 0;
562 }
563 
564 /*?
565  * This command displays sw_scheduler workers.
566  *
567  * @cliexpar
568  * Example of how to show workers:
569  * @cliexstart{show sw_scheduler workers}
570  * @cliexend
571  ?*/
572 /* *INDENT-OFF* */
574  .path = "show sw_scheduler workers",
575  .short_help = "show sw_scheduler workers",
576  .function = sw_scheduler_show_workers,
577  .is_mp_safe = 1,
578 };
579 /* *INDENT-ON* */
580 
581 clib_error_t *
583 {
584  return 0;
585 }
586 
588 
589 /* *INDENT-OFF* */
590 #define _(n, s, k, t, a) \
591  static vnet_crypto_async_frame_t \
592  *crypto_sw_scheduler_frame_dequeue_##n##_TAG_##t##_AAD_##a##_enc ( \
593  vlib_main_t *vm, u32 *nb_elts_processed, u32 * thread_idx) \
594  { \
595  return crypto_sw_scheduler_dequeue_aead ( \
596  vm, VNET_CRYPTO_OP_##n##_TAG##t##_AAD##a##_ENC, \
597  VNET_CRYPTO_OP_##n##_ENC, t, a, nb_elts_processed, thread_idx); \
598  } \
599  static vnet_crypto_async_frame_t \
600  *crypto_sw_scheduler_frame_dequeue_##n##_TAG_##t##_AAD_##a##_dec ( \
601  vlib_main_t *vm, u32 *nb_elts_processed, u32 * thread_idx) \
602  { \
603  return crypto_sw_scheduler_dequeue_aead ( \
604  vm, VNET_CRYPTO_OP_##n##_TAG##t##_AAD##a##_DEC, \
605  VNET_CRYPTO_OP_##n##_DEC, t, a, nb_elts_processed, thread_idx); \
606  }
608 #undef _
609 
610 #define _(c, h, s, k, d) \
611  static vnet_crypto_async_frame_t \
612  *crypto_sw_scheduler_frame_dequeue_##c##_##h##_TAG##d##_enc ( \
613  vlib_main_t *vm, u32 *nb_elts_processed, u32 * thread_idx) \
614  { \
615  return crypto_sw_scheduler_dequeue_link ( \
616  vm, VNET_CRYPTO_OP_##c##_##h##_TAG##d##_ENC, \
617  VNET_CRYPTO_OP_##c##_ENC, VNET_CRYPTO_OP_##h##_HMAC, d, 1, \
618  nb_elts_processed, thread_idx); \
619  } \
620  static vnet_crypto_async_frame_t \
621  *crypto_sw_scheduler_frame_dequeue_##c##_##h##_TAG##d##_dec ( \
622  vlib_main_t *vm, u32 *nb_elts_processed, u32 * thread_idx) \
623  { \
624  return crypto_sw_scheduler_dequeue_link ( \
625  vm, VNET_CRYPTO_OP_##c##_##h##_TAG##d##_DEC, \
626  VNET_CRYPTO_OP_##c##_DEC, VNET_CRYPTO_OP_##h##_HMAC, d, 0, \
627  nb_elts_processed, thread_idx); \
628  }
630 #undef _
631  /* *INDENT-ON* */
632 
634 clib_error_t *
636 {
639  clib_error_t *error = 0;
641 
642  u32 queue_size = CRYPTO_SW_SCHEDULER_QUEUE_SIZE * sizeof (void *)
643  + sizeof (crypto_sw_scheduler_queue_t);
644 
645  vec_validate_aligned (cm->per_thread_data, tm->n_vlib_mains - 1,
647 
648  vec_foreach (ptd, cm->per_thread_data)
649  {
650  ptd->self_crypto_enabled = 1;
651  u32 i;
652  for (i = 0; i < VNET_CRYPTO_ASYNC_OP_N_IDS; i++)
653  {
656  ASSERT (q != 0);
657  ptd->queues[i] = q;
658  clib_memset_u8 (q, 0, queue_size);
659  }
660  }
661 
662  cm->crypto_engine_index =
663  vnet_crypto_register_engine (vm, "sw_scheduler", 100,
664  "SW Scheduler Async Engine");
665 
666  vnet_crypto_register_key_handler (vm, cm->crypto_engine_index,
668 
670 
671  /* *INDENT-OFF* */
672 #define _(n, s, k, t, a) \
673  vnet_crypto_register_async_handler ( \
674  vm, cm->crypto_engine_index, \
675  VNET_CRYPTO_OP_##n##_TAG##t##_AAD##a##_ENC, \
676  crypto_sw_scheduler_frame_enqueue, \
677  crypto_sw_scheduler_frame_dequeue_##n##_TAG_##t##_AAD_##a##_enc); \
678  vnet_crypto_register_async_handler ( \
679  vm, cm->crypto_engine_index, \
680  VNET_CRYPTO_OP_##n##_TAG##t##_AAD##a##_DEC, \
681  crypto_sw_scheduler_frame_enqueue, \
682  crypto_sw_scheduler_frame_dequeue_##n##_TAG_##t##_AAD_##a##_dec);
684 #undef _
685 
686 #define _(c, h, s, k, d) \
687  vnet_crypto_register_async_handler ( \
688  vm, cm->crypto_engine_index, VNET_CRYPTO_OP_##c##_##h##_TAG##d##_ENC, \
689  crypto_sw_scheduler_frame_enqueue, \
690  crypto_sw_scheduler_frame_dequeue_##c##_##h##_TAG##d##_enc); \
691  vnet_crypto_register_async_handler ( \
692  vm, cm->crypto_engine_index, VNET_CRYPTO_OP_##c##_##h##_TAG##d##_DEC, \
693  crypto_sw_scheduler_frame_enqueue, \
694  crypto_sw_scheduler_frame_dequeue_##c##_##h##_TAG##d##_dec);
696 #undef _
697  /* *INDENT-ON* */
698 
699  if (error)
700  vec_free (cm->per_thread_data);
701 
702  return error;
703 }
704 
705 /* *INDENT-OFF* */
707  .runs_after = VLIB_INITS ("vnet_crypto_init"),
708 };
709 
711  .version = VPP_BUILD_VER,
712  .description = "SW Scheduler Crypto Async Engine plugin",
713 };
714 /* *INDENT-ON* */
715 
716 /*
717  * fd.io coding-style-patch-verification: ON
718  *
719  * Local Variables:
720  * eval: (c-set-style "gnu")
721  * End:
722  */
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
crypto_sw_scheduler_per_thread_data_t::chunks
vnet_crypto_op_chunk_t * chunks
Definition: crypto_sw_scheduler.h:40
sw_scheduler_cli_init
clib_error_t * sw_scheduler_cli_init(vlib_main_t *vm)
Definition: main.c:582
vlib.h
VNET_CRYPTO_KEY_OP_DEL
@ VNET_CRYPTO_KEY_OP_DEL
Definition: crypto.h:132
vlib_buffer_t::next_buffer
u32 next_buffer
Next buffer for this linked-list of buffers.
Definition: buffer.h:149
vlib_num_workers
static u32 vlib_num_workers()
Definition: threads.h:333
unformat_user
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
crypto_sw_scheduler_per_thread_data_t::queues
crypto_sw_scheduler_queue_t * queues[VNET_CRYPTO_ASYNC_OP_N_IDS]
Definition: crypto_sw_scheduler.h:35
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
vnet_crypto_async_frame_elt_t::integ_length_adj
u16 integ_length_adj
Definition: crypto.h:340
vnet_crypto_op_t::tag
u8 * tag
Definition: crypto.h:298
vnet_crypto_async_frame_elt_t::crypto_total_length
u32 crypto_total_length
Definition: crypto.h:336
foreach_crypto_aead_async_alg
#define foreach_crypto_aead_async_alg
async crypto
Definition: crypto.h:85
foreach_crypto_link_async_alg
#define foreach_crypto_link_async_alg
Definition: crypto.h:96
VNET_CRYPTO_ASYNC_OP_N_IDS
@ VNET_CRYPTO_ASYNC_OP_N_IDS
Definition: crypto.h:195
crypto_sw_scheduler_convert_link_crypto
static_always_inline void crypto_sw_scheduler_convert_link_crypto(vlib_main_t *vm, crypto_sw_scheduler_per_thread_data_t *ptd, vnet_crypto_key_t *key, vnet_crypto_async_frame_elt_t *fe, u32 index, u32 bi, vnet_crypto_op_id_t crypto_op_id, vnet_crypto_op_id_t integ_op_id, u32 digest_len, u8 is_enc)
Definition: main.c:227
VLIB_PLUGIN_REGISTER
VLIB_PLUGIN_REGISTER()
vlib_get_buffer
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:111
f
vlib_frame_t * f
Definition: interface_output.c:1098
vlib_get_worker_thread_index
static u32 vlib_get_worker_thread_index(u32 worker_index)
Definition: threads.h:339
unformat_line_input
unformat_function_t unformat_line_input
Definition: format.h:275
name
string name[64]
Definition: fib.api:25
vnet_crypto_op_t::status
vnet_crypto_op_status_t status
Definition: crypto.h:260
vlib_get_worker_index
static u32 vlib_get_worker_index(u32 thread_index)
Definition: threads.h:345
crypto_sw_scheduler_per_thread_data_t::crypto_ops
vnet_crypto_op_t * crypto_ops
Definition: crypto_sw_scheduler.h:36
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
vlib_cli_command_t::path
char * path
Definition: cli.h:96
crypto_sw_scheduler_main_t
Definition: crypto_sw_scheduler.h:44
vnet_crypto_op_t::src
u8 * src
Definition: crypto.h:277
u16
unsigned short u16
Definition: types.h:57
vnet_crypto_op_t::dst
u8 * dst
Definition: crypto.h:278
vnet_crypto_key_index_t
u32 vnet_crypto_key_index_t
Definition: crypto.h:378
vnet_crypto_async_frame_t
Definition: crypto.h:358
vnet_crypto_op_t::user_data
uword user_data
Definition: crypto.h:258
crypto_sw_scheduler_queue_t::head
u32 head
Definition: crypto_sw_scheduler.h:27
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
per_thread_data
Definition: main.c:66
vnet_crypto_async_frame_elt_t::crypto_start_offset
i16 crypto_start_offset
Definition: crypto.h:337
state
vl_api_dhcp_client_state_t state
Definition: dhcp.api:201
vnet_crypto_async_frame_t::state
vnet_crypto_async_frame_state_t state
Definition: crypto.h:361
vnet_crypto_op_t::iv
u8 * iv
Definition: crypto.h:293
VNET_CRYPTO_OP_FLAG_INIT_IV
#define VNET_CRYPTO_OP_FLAG_INIT_IV
Definition: crypto.h:262
unformat_input_t
struct _unformat_input_t unformat_input_t
vnet_crypto_op_t::len
u32 len
Definition: crypto.h:287
vlib_worker_threads
vlib_worker_thread_t * vlib_worker_threads
Definition: threads.c:35
crypto_sw_scheduler_main
foreach_crypto_link_async_alg crypto_sw_scheduler_main_t crypto_sw_scheduler_main
Definition: main.c:633
error
Definition: cJSON.c:88
vnet_crypto_register_engine
u32 vnet_crypto_register_engine(vlib_main_t *vm, char *name, int prio, char *desc)
Definition: crypto.c:112
cmd_set_sw_scheduler_worker_crypto
static vlib_cli_command_t cmd_set_sw_scheduler_worker_crypto
(constructor) VLIB_CLI_COMMAND (cmd_set_sw_scheduler_worker_crypto)
Definition: main.c:537
VNET_CRYPTO_FRAME_STATE_ELT_ERROR
@ VNET_CRYPTO_FRAME_STATE_ELT_ERROR
Definition: crypto.h:355
vnet_crypto_op_t::aad_len
u16 aad_len
Definition: crypto.h:271
key
typedef key
Definition: ipsec_types.api:91
process_chained_ops
static_always_inline void process_chained_ops(vlib_main_t *vm, vnet_crypto_async_frame_t *f, vnet_crypto_op_t *ops, vnet_crypto_op_chunk_t *chunks, u8 *state)
Definition: main.c:301
crypto_sw_scheduler_key_handler
static void crypto_sw_scheduler_key_handler(vlib_main_t *vm, vnet_crypto_key_op_t kop, vnet_crypto_key_index_t idx)
Definition: main.c:54
vnet_crypto_op_t
Definition: crypto.h:255
vnet_crypto_op_t::flags
u8 flags
Definition: crypto.h:261
crypto_sw_scheduler_dequeue_link
static_always_inline vnet_crypto_async_frame_t * crypto_sw_scheduler_dequeue_link(vlib_main_t *vm, vnet_crypto_async_op_id_t async_op_id, vnet_crypto_op_id_t sync_crypto_op_id, vnet_crypto_op_id_t sync_integ_op_id, u16 digest_len, u8 is_enc, u32 *nb_elts_processed, u32 *enqueue_thread_idx)
Definition: main.c:392
process_ops
static_always_inline void process_ops(vlib_main_t *vm, vnet_crypto_async_frame_t *f, vnet_crypto_op_t *ops, u8 *state)
Definition: main.c:275
vnet_crypto_op_t::key_index
u32 key_index
Definition: crypto.h:292
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
vnet_crypto_op_t::chunk_index
u32 chunk_index
Definition: crypto.h:289
VNET_CRYPTO_OP_FLAG_HMAC_CHECK
#define VNET_CRYPTO_OP_FLAG_HMAC_CHECK
Definition: crypto.h:263
i16
signed short i16
Definition: types.h:46
vlib_buffer_t::current_data
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:119
vlib_thread_main_t::n_vlib_mains
u32 n_vlib_mains
Definition: threads.h:262
count
u8 count
Definition: dhcp.api:208
vnet_crypto_process_ops
u32 vnet_crypto_process_ops(vlib_main_t *vm, vnet_crypto_op_t ops[], u32 n_ops)
Definition: crypto.c:99
crypto_sw_scheduler_queue_t
Definition: crypto_sw_scheduler.h:24
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
CLIB_MEMORY_STORE_BARRIER
#define CLIB_MEMORY_STORE_BARRIER()
Definition: clib.h:140
CRYPTO_SW_SCHEDULER_QUEUE_MASK
#define CRYPTO_SW_SCHEDULER_QUEUE_MASK
Definition: crypto_sw_scheduler.h:22
len
u8 len
Definition: ip_types.api:103
vec_add2
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:644
sw_scheduler_set_worker_crypto
static clib_error_t * sw_scheduler_set_worker_crypto(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: main.c:480
vnet_crypto_async_frame_elt_t::key_index
u32 key_index
Definition: crypto.h:335
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
offset
struct clib_bihash_value offset
template key/value backing page structure
vnet_crypto_process_chained_ops
u32 vnet_crypto_process_chained_ops(vlib_main_t *vm, vnet_crypto_op_t ops[], vnet_crypto_op_chunk_t *chunks, u32 n_ops)
Definition: crypto.c:105
crypto_sw_scheduler_per_thread_data_t::chained_crypto_ops
vnet_crypto_op_t * chained_crypto_ops
Definition: crypto_sw_scheduler.h:38
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
vec_validate_aligned
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:534
crypto_sw_scheduler_convert_aead
static_always_inline void crypto_sw_scheduler_convert_aead(vlib_main_t *vm, crypto_sw_scheduler_per_thread_data_t *ptd, vnet_crypto_async_frame_elt_t *fe, u32 index, u32 bi, vnet_crypto_op_id_t op_id, u16 aad_len, u8 tag_len)
Definition: main.c:192
vnet_crypto_op_chunk_t::src
u8 * src
Definition: crypto.h:250
VNET_CRYPTO_OP_FLAG_CHAINED_BUFFERS
#define VNET_CRYPTO_OP_FLAG_CHAINED_BUFFERS
Definition: crypto.h:264
static_always_inline
#define static_always_inline
Definition: clib.h:112
vnet_crypto_op_t::op
vnet_crypto_op_id_t op
Definition: crypto.h:259
vec_foreach_index
#define vec_foreach_index(var, v)
Iterate over vector indices.
Definition: vec_bootstrap.h:220
crypto_sw_scheduler_per_thread_data_t::integ_ops
vnet_crypto_op_t * integ_ops
Definition: crypto_sw_scheduler.h:37
vlib_thread_main
vlib_thread_main_t vlib_thread_main
Definition: threads.c:36
vlib_main_t::thread_index
u32 thread_index
Definition: main.h:215
vnet_crypto_op_id_t
vnet_crypto_op_id_t
Definition: crypto.h:219
CRYPTO_SW_SCHEDULER_QUEUE_SIZE
#define CRYPTO_SW_SCHEDULER_QUEUE_SIZE
Definition: crypto_sw_scheduler.h:21
cm
vnet_feature_config_main_t * cm
Definition: nat44_ei_hairpinning.c:594
format_unformat_error
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
vnet_crypto_get_key
static_always_inline vnet_crypto_key_t * vnet_crypto_get_key(vnet_crypto_key_index_t index)
Definition: crypto.h:548
vnet_crypto_async_frame_elt_t::flags
u8 flags
share same VNET_CRYPTO_OP_FLAG_* values
Definition: crypto.h:342
vnet_crypto_op_chunk_t
Definition: crypto.h:248
crypto_sw_scheduler_per_thread_data_t
Definition: crypto_sw_scheduler.h:32
clib_min
#define clib_min(x, y)
Definition: clib.h:342
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
crypto_sw_scheduler_get_completed_frame
static_always_inline vnet_crypto_async_frame_t * crypto_sw_scheduler_get_completed_frame(crypto_sw_scheduler_queue_t *q)
Definition: main.c:124
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
clib_memset_u8
static_always_inline void clib_memset_u8(void *p, u8 val, uword count)
Definition: string.h:441
vlib_buffer_t::current_length
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:122
vlib_buffer_space_left_at_end
static u32 vlib_buffer_space_left_at_end(vlib_main_t *vm, vlib_buffer_t *b)
Definition: buffer_funcs.h:1462
crypto_sw_scheduler_init
clib_error_t * crypto_sw_scheduler_init(vlib_main_t *vm)
Definition: main.c:635
plugin.h
vnet_crypto_op_t::n_chunks
u16 n_chunks
Definition: crypto.h:282
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
vnet_crypto_op_chunk_t::dst
u8 * dst
Definition: crypto.h:251
index
u32 index
Definition: flow_types.api:221
clib_bihash_value
template key/value backing page structure
Definition: bihash_doc.h:44
vnet_crypto_async_frame_elt_t::aad
u8 * aad
Definition: crypto.h:334
vnet_crypto_op_t::tag_len
u8 tag_len
Definition: crypto.h:269
crypto_sw_scheduler_queue_t::jobs
vnet_crypto_async_frame_t * jobs[0]
Definition: crypto_sw_scheduler.h:29
vnet_crypto_register_key_handler
void vnet_crypto_register_key_handler(vlib_main_t *vm, u32 engine_index, vnet_crypto_key_handler_t *key_handler)
Definition: crypto.c:316
u64
unsigned long u64
Definition: types.h:89
vnet_crypto_op_t::aad
u8 * aad
Definition: crypto.h:294
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
vnet_crypto_key_t
Definition: crypto.h:198
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
vlib_thread_main_t
Definition: threads.h:243
clib_prefetch_load
static_always_inline void clib_prefetch_load(void *p)
Definition: cache.h:92
crypto_sw_scheduler_frame_enqueue
static int crypto_sw_scheduler_frame_enqueue(vlib_main_t *vm, vnet_crypto_async_frame_t *frame)
Definition: main.c:77
VNET_CRYPTO_FRAME_STATE_SUCCESS
@ VNET_CRYPTO_FRAME_STATE_SUCCESS
Definition: crypto.h:354
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
crypto_sw_scheduler_dequeue_aead
static_always_inline vnet_crypto_async_frame_t * crypto_sw_scheduler_dequeue_aead(vlib_main_t *vm, vnet_crypto_async_op_id_t async_op_id, vnet_crypto_op_id_t sync_op_id, u8 tag_len, u8 aad_len, u32 *nb_elts_processed, u32 *enqueue_thread_idx)
Definition: main.c:328
crypto_sw_scheduler_per_thread_data_t::self_crypto_enabled
u8 self_crypto_enabled
Definition: crypto_sw_scheduler.h:41
vnet_crypto_async_frame_elt_t::integ_start_offset
i16 integ_start_offset
Definition: crypto.h:338
vnet_crypto_key_op_t
vnet_crypto_key_op_t
Definition: crypto.h:129
VNET_CRYPTO_FRAME_STATE_PENDING
@ VNET_CRYPTO_FRAME_STATE_PENDING
Definition: crypto.h:352
vlib_main_t
Definition: main.h:102
VLIB_INITS
#define VLIB_INITS(...)
Definition: init.h:352
crypto_sw_scheduler_get_pending_frame
static_always_inline vnet_crypto_async_frame_t * crypto_sw_scheduler_get_pending_frame(crypto_sw_scheduler_queue_t *q)
Definition: main.c:101
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vnet_crypto_async_op_id_t
vnet_crypto_async_op_id_t
Definition: crypto.h:182
vlib_buffer_get_current
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:257
vnet_crypto_async_frame_elt_t::tag
u8 * tag
Definition: crypto.h:332
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
crypto_sw_scheduler_api_init
clib_error_t * crypto_sw_scheduler_api_init(vlib_main_t *vm)
Definition: api.c:63
vlib_buffer_t::data
u8 data[]
Packet data.
Definition: buffer.h:204
i
int i
Definition: flowhash_template.h:376
vnet_crypto_async_frame_elt_t::iv
u8 * iv
Definition: crypto.h:328
cryptodev_sw_scheduler_sgl
static_always_inline void cryptodev_sw_scheduler_sgl(vlib_main_t *vm, crypto_sw_scheduler_per_thread_data_t *ptd, vlib_buffer_t *b, vnet_crypto_op_t *op, i16 offset, u32 len)
Definition: main.c:141
clib_mem_alloc_aligned
static void * clib_mem_alloc_aligned(uword size, uword align)
Definition: mem.h:264
rv
int __clib_unused rv
Definition: application.c:491
crypto_sw_scheduler_queue_t::tail
u32 tail
Definition: crypto_sw_scheduler.h:28
crypto_sw_scheduler.h
crypto_sw_scheduler_set_worker_crypto
int crypto_sw_scheduler_set_worker_crypto(u32 worker_idx, u8 enabled)
Definition: main.c:23
vnet_crypto_async_frame_elt_t
Definition: crypto.h:326
vlib_cli_command_t
Definition: cli.h:92
vnet_crypto_op_chunk_t::len
u32 len
Definition: crypto.h:252
vlib_get_thread_main
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:56
cmd_show_sw_scheduler_workers
static vlib_cli_command_t cmd_show_sw_scheduler_workers
(constructor) VLIB_CLI_COMMAND (cmd_show_sw_scheduler_workers)
Definition: main.c:573
sw_scheduler_show_workers
static clib_error_t * sw_scheduler_show_workers(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: main.c:546
clib_atomic_bool_cmp_and_swap
#define clib_atomic_bool_cmp_and_swap(addr, old, new)
Definition: atomics.h:38
VNET_CRYPTO_KEY_TYPE_LINK
#define VNET_CRYPTO_KEY_TYPE_LINK
Definition: crypto.h:215
VNET_CRYPTO_FRAME_STATE_WORK_IN_PROGRESS
@ VNET_CRYPTO_FRAME_STATE_WORK_IN_PROGRESS
Definition: crypto.h:353
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
Definition: buffer.h:133
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
vnet_crypto_async_frame_elt_t::digest
u8 * digest
Definition: crypto.h:331
crypto_sw_scheduler_per_thread_data_t::chained_integ_ops
vnet_crypto_op_t * chained_integ_ops
Definition: crypto_sw_scheduler.h:39