FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
esp_encrypt.c
Go to the documentation of this file.
1 /*
2  * esp_encrypt.c : IPSec ESP encrypt node using DPDK Cryptodev
3  *
4  * Copyright (c) 2016 Intel and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include <vnet/vnet.h>
19 #include <vnet/api_errno.h>
20 #include <vnet/ip/ip.h>
21 
22 #include <vnet/ipsec/ipsec.h>
23 #include <dpdk/ipsec/ipsec.h>
24 #include <dpdk/ipsec/esp.h>
25 #include <dpdk/device/dpdk.h>
26 #include <dpdk/device/dpdk_priv.h>
27 
28 #define foreach_esp_encrypt_next \
29 _(DROP, "error-drop") \
30 _(IP4_LOOKUP, "ip4-lookup") \
31 _(IP6_LOOKUP, "ip6-lookup") \
32 _(INTERFACE_OUTPUT, "interface-output")
33 
34 #define _(v, s) ESP_ENCRYPT_NEXT_##v,
35 typedef enum
36 {
38 #undef _
41 
42 #define foreach_esp_encrypt_error \
43  _(RX_PKTS, "ESP pkts received") \
44  _(SEQ_CYCLED, "sequence number cycled") \
45  _(ENQ_FAIL, "Enqueue failed (buffer full)") \
46  _(NO_CRYPTODEV, "Cryptodev not configured")
47 
48 
49 typedef enum
50 {
51 #define _(sym,str) ESP_ENCRYPT_ERROR_##sym,
53 #undef _
56 
57 static char *esp_encrypt_error_strings[] = {
58 #define _(sym,string) string,
60 #undef _
61 };
62 
64 
65 typedef struct
66 {
67  u32 spi;
68  u32 seq;
69  ipsec_crypto_alg_t crypto_alg;
70  ipsec_integ_alg_t integ_alg;
72 
73 /* packet trace format function */
74 static u8 *
75 format_esp_encrypt_trace (u8 * s, va_list * args)
76 {
77  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
78  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
79  esp_encrypt_trace_t *t = va_arg (*args, esp_encrypt_trace_t *);
80 
81  s = format (s, "esp: spi %u seq %u crypto %U integrity %U",
82  t->spi, t->seq,
85  return s;
86 }
87 
88 static uword
90  vlib_node_runtime_t * node,
91  vlib_frame_t * from_frame)
92 {
93  u32 n_left_from, *from, *to_next, next_index;
94  ipsec_main_t *im = &ipsec_main;
95  u32 thread_index = vlib_get_thread_index ();
98  u32 i;
99 
100  from = vlib_frame_vector_args (from_frame);
101  n_left_from = from_frame->n_vectors;
102 
103  crypto_worker_main_t *cwm =
104  vec_elt_at_index (dcm->workers_main, thread_index);
105  u32 n_qps = vec_len (cwm->qp_data);
106  struct rte_crypto_op **cops_to_enq[n_qps];
107  u32 n_cop_qp[n_qps], *bi_to_enq[n_qps];
108 
109  for (i = 0; i < n_qps; i++)
110  {
111  bi_to_enq[i] = cwm->qp_data[i].bi;
112  cops_to_enq[i] = cwm->qp_data[i].cops;
113  }
114 
115  memset (n_cop_qp, 0, n_qps * sizeof (u32));
116 
118 
119  next_index = ESP_ENCRYPT_NEXT_DROP;
120 
121  while (n_left_from > 0)
122  {
123  u32 n_left_to_next;
124 
125  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
126 
127  while (n_left_from > 0 && n_left_to_next > 0)
128  {
129  u32 bi0, next0;
130  vlib_buffer_t *b0 = 0;
131  u32 sa_index0;
132  ipsec_sa_t *sa0;
133  ip4_and_esp_header_t *ih0, *oh0 = 0;
134  ip6_and_esp_header_t *ih6_0, *oh6_0 = 0;
135  struct rte_mbuf *mb0 = 0;
136  esp_footer_t *f0;
137  u8 is_ipv6;
138  u8 ip_hdr_size;
139  u8 next_hdr_type;
140  u8 transport_mode = 0;
141  const int BLOCK_SIZE = 16;
142  u32 iv_size;
143  u16 orig_sz;
144  u8 trunc_size;
145  crypto_sa_session_t *sa_sess;
146  void *sess;
147  struct rte_crypto_op *cop = 0;
148  u16 qp_index;
149 
150  bi0 = from[0];
151  from += 1;
152  n_left_from -= 1;
153 
154  b0 = vlib_get_buffer (vm, bi0);
155  sa_index0 = vnet_buffer (b0)->ipsec.sad_index;
156  sa0 = pool_elt_at_index (im->sad, sa_index0);
157 
158  if (PREDICT_FALSE (esp_seq_advance (sa0)))
159  {
160  clib_warning ("sequence number counter has cycled SPI %u",
161  sa0->spi);
163  ESP_ENCRYPT_ERROR_SEQ_CYCLED, 1);
164  //TODO: rekey SA
165  to_next[0] = bi0;
166  to_next += 1;
167  n_left_to_next -= 1;
168  goto trace;
169  }
170 
171  sa0->total_data_size += b0->current_length;
172 
173  sa_sess = pool_elt_at_index (cwm->sa_sess_d[1], sa_index0);
174  if (PREDICT_FALSE (!sa_sess->sess))
175  {
176  int ret = create_sym_sess (sa0, sa_sess, 1);
177 
178  if (PREDICT_FALSE (ret))
179  {
180  to_next[0] = bi0;
181  to_next += 1;
182  n_left_to_next -= 1;
183  goto trace;
184  }
185  }
186 
187  qp_index = sa_sess->qp_index;
188  sess = sa_sess->sess;
189 
190  ASSERT (vec_len (vec_elt (cwm->qp_data, qp_index).free_cops) > 0);
191  cop = vec_pop (vec_elt (cwm->qp_data, qp_index).free_cops);
192  ASSERT (cop->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED);
193 
194  cops_to_enq[qp_index][0] = cop;
195  cops_to_enq[qp_index] += 1;
196  n_cop_qp[qp_index] += 1;
197  bi_to_enq[qp_index][0] = bi0;
198  bi_to_enq[qp_index] += 1;
199 
200  ssize_t adv;
201  iv_size = em->esp_crypto_algs[sa0->crypto_alg].iv_len;
202  if (sa0->crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
203  trunc_size = 16;
204  else
205  trunc_size = em->esp_integ_algs[sa0->integ_alg].trunc_size;
206 
207  ih0 = vlib_buffer_get_current (b0);
208  orig_sz = b0->current_length;
209  is_ipv6 = (ih0->ip4.ip_version_and_header_length & 0xF0) == 0x60;
210  /* is ipv6 */
211  if (PREDICT_TRUE (sa0->is_tunnel))
212  {
213  if (PREDICT_TRUE (!is_ipv6))
214  adv = -sizeof (ip4_and_esp_header_t);
215  else
216  adv = -sizeof (ip6_and_esp_header_t);
217  }
218  else
219  {
220  adv = -sizeof (esp_header_t);
221  if (PREDICT_TRUE (!is_ipv6))
222  orig_sz -= sizeof (ip4_header_t);
223  else
224  orig_sz -= sizeof (ip6_header_t);
225  }
226 
227  /*transport mode save the eth header before it is overwritten */
228  if (PREDICT_FALSE (!sa0->is_tunnel))
229  {
231  ((u8 *) vlib_buffer_get_current (b0) -
232  sizeof (ethernet_header_t));
233  ethernet_header_t *oeh0 =
234  (ethernet_header_t *) ((u8 *) ieh0 + (adv - iv_size));
235  clib_memcpy (oeh0, ieh0, sizeof (ethernet_header_t));
236  }
237 
238  vlib_buffer_advance (b0, adv - iv_size);
239 
240  /* XXX IP6/ip4 and IP4/IP6 not supported, only IP4/IP4 and IP6/IP6 */
241 
242  /* is ipv6 */
243  if (PREDICT_FALSE (is_ipv6))
244  {
245  ih6_0 = (ip6_and_esp_header_t *) ih0;
246  ip_hdr_size = sizeof (ip6_header_t);
247  oh6_0 = vlib_buffer_get_current (b0);
248 
249  if (PREDICT_TRUE (sa0->is_tunnel))
250  {
251  next_hdr_type = IP_PROTOCOL_IPV6;
252  oh6_0->ip6.ip_version_traffic_class_and_flow_label =
253  ih6_0->ip6.ip_version_traffic_class_and_flow_label;
254  }
255  else
256  {
257  next_hdr_type = ih6_0->ip6.protocol;
258  memmove (oh6_0, ih6_0, sizeof (ip6_header_t));
259  }
260 
261  oh6_0->ip6.protocol = IP_PROTOCOL_IPSEC_ESP;
262  oh6_0->ip6.hop_limit = 254;
263  oh6_0->esp.spi = clib_net_to_host_u32 (sa0->spi);
264  oh6_0->esp.seq = clib_net_to_host_u32 (sa0->seq);
265  }
266  else
267  {
268  ip_hdr_size = sizeof (ip4_header_t);
269  oh0 = vlib_buffer_get_current (b0);
270 
271  if (PREDICT_TRUE (sa0->is_tunnel))
272  {
273  next_hdr_type = IP_PROTOCOL_IP_IN_IP;
274  oh0->ip4.tos = ih0->ip4.tos;
275  }
276  else
277  {
278  next_hdr_type = ih0->ip4.protocol;
279  memmove (oh0, ih0, sizeof (ip4_header_t));
280  }
281 
282  oh0->ip4.ip_version_and_header_length = 0x45;
283  oh0->ip4.fragment_id = 0;
284  oh0->ip4.flags_and_fragment_offset = 0;
285  oh0->ip4.ttl = 254;
286  oh0->ip4.protocol = IP_PROTOCOL_IPSEC_ESP;
287  oh0->esp.spi = clib_net_to_host_u32 (sa0->spi);
288  oh0->esp.seq = clib_net_to_host_u32 (sa0->seq);
289  }
290 
291  if (PREDICT_TRUE
292  (!is_ipv6 && sa0->is_tunnel && !sa0->is_tunnel_ip6))
293  {
294  oh0->ip4.src_address.as_u32 = sa0->tunnel_src_addr.ip4.as_u32;
295  oh0->ip4.dst_address.as_u32 = sa0->tunnel_dst_addr.ip4.as_u32;
296 
297  /* in tunnel mode send it back to FIB */
298  next0 = ESP_ENCRYPT_NEXT_IP4_LOOKUP;
299  vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0;
300  }
301  else if (is_ipv6 && sa0->is_tunnel && sa0->is_tunnel_ip6)
302  {
303  oh6_0->ip6.src_address.as_u64[0] =
304  sa0->tunnel_src_addr.ip6.as_u64[0];
305  oh6_0->ip6.src_address.as_u64[1] =
306  sa0->tunnel_src_addr.ip6.as_u64[1];
307  oh6_0->ip6.dst_address.as_u64[0] =
308  sa0->tunnel_dst_addr.ip6.as_u64[0];
309  oh6_0->ip6.dst_address.as_u64[1] =
310  sa0->tunnel_dst_addr.ip6.as_u64[1];
311 
312  /* in tunnel mode send it back to FIB */
313  next0 = ESP_ENCRYPT_NEXT_IP6_LOOKUP;
314  vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0;
315  }
316  else
317  {
318  next0 = ESP_ENCRYPT_NEXT_INTERFACE_OUTPUT;
319  transport_mode = 1;
320  }
321 
322  int blocks = 1 + (orig_sz + 1) / BLOCK_SIZE;
323 
324  /* pad packet in input buffer */
325  u8 pad_bytes = BLOCK_SIZE * blocks - 2 - orig_sz;
326  u8 i;
328 
329  for (i = 0; i < pad_bytes; ++i)
330  padding[i] = i + 1;
331 
332  f0 = vlib_buffer_get_current (b0) + b0->current_length + pad_bytes;
333  f0->pad_length = pad_bytes;
334  f0->next_header = next_hdr_type;
335  b0->current_length += pad_bytes + 2 + trunc_size;
336 
337  vnet_buffer (b0)->sw_if_index[VLIB_RX] =
338  vnet_buffer (b0)->sw_if_index[VLIB_RX];
340 
341  struct rte_crypto_sym_op *sym_cop;
342  sym_cop = (struct rte_crypto_sym_op *) (cop + 1);
343 
344  dpdk_cop_priv_t *priv = (dpdk_cop_priv_t *) (sym_cop + 1);
345 
346  vnet_buffer (b0)->unused[0] = next0;
347 
348  mb0 = rte_mbuf_from_vlib_buffer (b0);
349  mb0->data_len = b0->current_length;
350  mb0->pkt_len = b0->current_length;
351  mb0->data_off = RTE_PKTMBUF_HEADROOM + b0->current_data;
352 
353  dpdk_gcm_cnt_blk *icb = &priv->cb;
354 
355  crypto_set_icb (icb, sa0->salt, sa0->seq, sa0->seq_hi);
356 
357  u8 is_aead = sa0->crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128;
358  u32 cipher_off, cipher_len;
359  u32 auth_off = 0, auth_len = 0, aad_size = 0;
360  u8 *aad = NULL, *digest = NULL;
361  u64 digest_paddr;
362 
363  digest =
364  vlib_buffer_get_current (b0) + b0->current_length - trunc_size;
365 
366  digest_paddr = mb0->buf_physaddr + (digest - (u8 *) mb0->buf_addr);
367 
368  if (is_aead)
369  {
370  u32 *esp_iv =
371  (u32 *) (b0->data + b0->current_data + ip_hdr_size +
372  sizeof (esp_header_t));
373  esp_iv[0] = sa0->seq;
374  esp_iv[1] = sa0->seq_hi;
375 
376  cipher_off = ip_hdr_size + sizeof (esp_header_t) + iv_size;
377  cipher_len = BLOCK_SIZE * blocks;
378  iv_size = 16; /* GCM IV size, not ESP IV size */
379 
380  aad = priv->aad;
381  clib_memcpy (aad, vlib_buffer_get_current (b0) + ip_hdr_size,
382  8);
383  aad_size = 8;
384  if (PREDICT_FALSE (sa0->use_esn))
385  {
386  *((u32 *) & aad[8]) = sa0->seq_hi;
387  aad_size = 12;
388  }
389  }
390  else
391  {
392  cipher_off = ip_hdr_size + sizeof (esp_header_t);
393  cipher_len = BLOCK_SIZE * blocks + iv_size;
394 
395  auth_off = ip_hdr_size;
396  auth_len = b0->current_length - ip_hdr_size - trunc_size;
397 
398  if (PREDICT_FALSE (sa0->use_esn))
399  {
400  *((u32 *) digest) = sa0->seq_hi;
401  auth_len += sizeof (sa0->seq_hi);
402  }
403  }
404 
405  crypto_op_setup (is_aead, mb0, cop, sess,
406  cipher_off, cipher_len, (u8 *) icb, iv_size,
407  auth_off, auth_len, aad, aad_size,
408  digest, digest_paddr, trunc_size);
409 
410  if (PREDICT_FALSE (is_ipv6))
411  {
412  oh6_0->ip6.payload_length =
413  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0) -
414  sizeof (ip6_header_t));
415  }
416  else
417  {
418  oh0->ip4.length =
419  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0));
420  oh0->ip4.checksum = ip4_header_checksum (&oh0->ip4);
421  }
422 
423  if (transport_mode)
424  vlib_buffer_advance (b0, -sizeof (ethernet_header_t));
425 
426  trace:
428  {
429  esp_encrypt_trace_t *tr =
430  vlib_add_trace (vm, node, b0, sizeof (*tr));
431  tr->spi = sa0->spi;
432  tr->seq = sa0->seq - 1;
433  tr->crypto_alg = sa0->crypto_alg;
434  tr->integ_alg = sa0->integ_alg;
435  }
436  }
437  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
438  }
440  ESP_ENCRYPT_ERROR_RX_PKTS,
441  from_frame->n_vectors);
442  crypto_qp_data_t *qpd;
443  /* *INDENT-OFF* */
444  vec_foreach_index (i, cwm->qp_data)
445  {
446  u32 enq;
447 
448  if (!n_cop_qp[i])
449  continue;
450 
451  qpd = vec_elt_at_index(cwm->qp_data, i);
452  enq = rte_cryptodev_enqueue_burst(qpd->dev_id, qpd->qp_id,
453  qpd->cops, n_cop_qp[i]);
454  qpd->inflights += enq;
455 
456  if (PREDICT_FALSE(enq < n_cop_qp[i]))
457  {
458  crypto_free_cop (qpd, &qpd->cops[enq], n_cop_qp[i] - enq);
459  vlib_buffer_free (vm, &qpd->bi[enq], n_cop_qp[i] - enq);
460 
462  ESP_ENCRYPT_ERROR_ENQ_FAIL,
463  n_cop_qp[i] - enq);
464  }
465  }
466  /* *INDENT-ON* */
467 
468  return from_frame->n_vectors;
469 }
470 
471 /* *INDENT-OFF* */
473  .function = dpdk_esp_encrypt_node_fn,
474  .name = "dpdk-esp-encrypt",
475  .flags = VLIB_NODE_FLAG_IS_OUTPUT,
476  .vector_size = sizeof (u32),
477  .format_trace = format_esp_encrypt_trace,
478  .n_errors = ARRAY_LEN (esp_encrypt_error_strings),
479  .error_strings = esp_encrypt_error_strings,
480  .n_next_nodes = 1,
481  .next_nodes =
482  {
483  [ESP_ENCRYPT_NEXT_DROP] = "error-drop",
484  }
485 };
486 /* *INDENT-ON* */
487 
489 /*
490  * ESP Encrypt Post Node
491  */
492 #define foreach_esp_encrypt_post_error \
493  _(PKTS, "ESP post pkts")
494  typedef enum
495  {
496 #define _(sym,str) ESP_ENCRYPT_POST_ERROR_##sym,
498 #undef _
501 
503 #define _(sym,string) string,
505 #undef _
506  };
507 
509 
510 static u8 *
511 format_esp_encrypt_post_trace (u8 * s, va_list * args)
512 {
513  return s;
514 }
515 
516 static uword
518  vlib_node_runtime_t * node,
519  vlib_frame_t * from_frame)
520 {
521  u32 n_left_from, *from, *to_next = 0, next_index;
522 
523  from = vlib_frame_vector_args (from_frame);
524  n_left_from = from_frame->n_vectors;
525 
526  next_index = node->cached_next_index;
527 
528  while (n_left_from > 0)
529  {
530  u32 n_left_to_next;
531 
532  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
533 
534  while (n_left_from > 0 && n_left_to_next > 0)
535  {
536  u32 bi0, next0;
537  vlib_buffer_t *b0 = 0;
538 
539  bi0 = from[0];
540  from += 1;
541  n_left_from -= 1;
542  n_left_to_next -= 1;
543 
544  b0 = vlib_get_buffer (vm, bi0);
545 
546  to_next[0] = bi0;
547  to_next += 1;
548 
549  next0 = vnet_buffer (b0)->unused[0];
550 
551  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
552  to_next, n_left_to_next, bi0,
553  next0);
554  }
555  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
556  }
557 
559  ESP_ENCRYPT_POST_ERROR_PKTS,
560  from_frame->n_vectors);
561 
562  return from_frame->n_vectors;
563 }
564 
565 /* *INDENT-OFF* */
567  .function = dpdk_esp_encrypt_post_node_fn,
568  .name = "dpdk-esp-encrypt-post",
569  .vector_size = sizeof (u32),
570  .format_trace = format_esp_encrypt_post_trace,
571  .type = VLIB_NODE_TYPE_INTERNAL,
573  .error_strings = esp_encrypt_post_error_strings,
574  .n_next_nodes = ESP_ENCRYPT_N_NEXT,
575  .next_nodes =
576  {
577 #define _(s,n) [ESP_ENCRYPT_NEXT_##s] = n,
579 #undef _
580  }
581 };
582 /* *INDENT-ON* */
583 
586 /*
587  * fd.io coding-style-patch-verification: ON
588  *
589  * Local Variables:
590  * eval: (c-set-style "gnu")
591  * End:
592  */
u32 bi[VLIB_FRAME_SIZE]
Definition: ipsec.h:65
#define vec_foreach_index(var, v)
Iterate over vector indices.
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:337
#define CLIB_UNUSED(x)
Definition: clib.h:79
ip46_address_t tunnel_src_addr
Definition: ipsec.h:119
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
Definition: buffer_funcs.h:317
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
Definition: memory_vlib.c:1296
u8 aad[12]
Definition: ipsec.h:46
#define PREDICT_TRUE(x)
Definition: clib.h:98
#define NULL
Definition: clib.h:55
static_always_inline i32 create_sym_sess(ipsec_sa_t *sa, crypto_sa_session_t *sa_sess, u8 is_outbound)
Definition: esp.h:203
ipsec_integ_alg_t integ_alg
Definition: ipsec.h:110
static u8 * format_esp_encrypt_trace(u8 *s, va_list *args)
Definition: esp_encrypt.c:75
u32 padding
Definition: vhost-user.h:77
u8 is_tunnel
Definition: ipsec.h:117
struct _vlib_node_registration vlib_node_registration_t
ipsec_integ_alg_t integ_alg
Definition: esp_encrypt.c:68
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
ipsec_crypto_alg_t crypto_alg
Definition: esp_encrypt.c:67
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
Definition: buffer_funcs.h:107
#define vec_pop(V)
Returns last element of a vector and decrements its length.
Definition: vec.h:612
static_always_inline void crypto_free_cop(crypto_qp_data_t *qpd, struct rte_crypto_op **cops, u32 n)
Definition: ipsec.h:131
dpdk_crypto_main_t dpdk_crypto_main
Definition: ipsec.h:92
u32 spi
Definition: ipsec.h:103
u32 seq_hi
Definition: ipsec.h:126
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:68
vlib_node_registration_t dpdk_esp_encrypt_post_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp_encrypt_post_node)
Definition: esp_encrypt.c:508
static_always_inline void crypto_alloc_cops()
Definition: ipsec.h:99
ipsec_main_t ipsec_main
Definition: ipsec.h:282
u8 use_esn
Definition: ipsec.h:114
#define VLIB_BUFFER_TOTAL_LENGTH_VALID
Definition: buffer.h:97
dpdk_esp_main_t dpdk_esp_main
Definition: esp.h:44
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
vlib_node_registration_t dpdk_esp_encrypt_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp_encrypt_node)
Definition: esp_encrypt.c:63
unsigned long u64
Definition: types.h:89
dpdk_esp_integ_alg_t * esp_integ_algs
Definition: esp.h:41
i16 inflights
Definition: ipsec.h:64
u8 * format_ipsec_crypto_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:58
dpdk_esp_crypto_alg_t * esp_crypto_algs
Definition: esp.h:40
esp_encrypt_error_t
Definition: esp_encrypt.c:47
#define rte_mbuf_from_vlib_buffer(x)
Definition: dpdk_priv.h:16
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:458
ipsec_integ_alg_t
Definition: ipsec.h:86
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:72
u8 is_tunnel_ip6
Definition: ipsec.h:118
u32 salt
Definition: ipsec.h:122
static_always_inline void crypto_op_setup(u8 is_aead, struct rte_mbuf *mb0, struct rte_crypto_op *cop, void *session, u32 cipher_off, u32 cipher_len, u8 *icb __unused, u32 iv_size __unused, u32 auth_off, u32 auth_len, u8 *aad __unused, u32 aad_size __unused, u8 *digest, u64 digest_paddr, u32 digest_size __unused)
Definition: esp.h:322
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:193
#define PREDICT_FALSE(x)
Definition: clib.h:97
struct rte_crypto_op * cops[VLIB_FRAME_SIZE]
Definition: ipsec.h:66
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
Definition: buffer_node.h:216
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
Definition: node_funcs.h:364
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1158
ip46_address_t tunnel_dst_addr
Definition: ipsec.h:120
dpdk_gcm_cnt_blk cb
Definition: ipsec.h:43
u16 n_vectors
Definition: node.h:344
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:221
vlib_main_t * vm
Definition: buffer.c:283
#define foreach_esp_encrypt_error
Definition: esp_encrypt.c:42
#define clib_warning(format, args...)
Definition: error.h:59
#define VLIB_BUFFER_IS_TRACED
Definition: buffer.h:93
#define foreach_esp_encrypt_post_error
Definition: esp_encrypt.c:492
#define clib_memcpy(a, b, c)
Definition: string.h:69
static char * esp_encrypt_error_strings[]
Definition: esp_encrypt.c:57
#define ARRAY_LEN(x)
Definition: clib.h:59
esp_encrypt_next_t
Definition: esp_encrypt.c:33
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
Definition: main.c:454
esp_encrypt_post_error_t
Definition: esp_encrypt.c:494
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:456
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
static_always_inline void crypto_set_icb(dpdk_gcm_cnt_blk *icb, u32 salt, u32 seq, u32 seq_hi)
Definition: esp.h:310
ipsec_sa_t * sad
Definition: ipsec.h:247
ipsec_crypto_alg_t
Definition: ipsec.h:68
crypto_worker_main_t * workers_main
Definition: ipsec.h:88
u64 total_data_size
Definition: ipsec.h:132
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:206
crypto_qp_data_t * qp_data
Definition: ipsec.h:79
crypto_sa_session_t * sa_sess_d[2]
Definition: ipsec.h:78
u32 seq
Definition: ipsec.h:125
u64 uword
Definition: types.h:112
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace_funcs.h:55
#define vec_elt(v, i)
Get vector value at index i.
u8 * format_ipsec_integ_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:90
#define VLIB_NODE_FLAG_IS_OUTPUT
Definition: node.h:253
Definition: defs.h:47
unsigned short u16
Definition: types.h:57
static char * esp_encrypt_post_error_strings[]
Definition: esp_encrypt.c:502
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:267
static uword dpdk_esp_encrypt_post_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: esp_encrypt.c:517
#define vnet_buffer(b)
Definition: buffer.h:306
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
Definition: node.h:158
ipsec_crypto_alg_t crypto_alg
Definition: ipsec.h:106
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
u8 data[0]
Packet data.
Definition: buffer.h:157
static uword dpdk_esp_encrypt_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: esp_encrypt.c:89
#define foreach_esp_encrypt_next
Definition: esp_encrypt.c:28
static int esp_seq_advance(ipsec_sa_t *sa)
Definition: esp.h:207
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:75
static u8 * format_esp_encrypt_post_trace(u8 *s, va_list *args)
Definition: esp_encrypt.c:511
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:57
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:239
Definition: defs.h:46