DPDK  20.11.0
rte_ipsec_group.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Intel Corporation
3  */
4 
5 #ifndef _RTE_IPSEC_GROUP_H_
6 #define _RTE_IPSEC_GROUP_H_
7 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
28  union {
29  uint64_t val;
30  void *ptr;
31  } id;
32  struct rte_mbuf **m;
33  uint32_t cnt;
34  int32_t rc;
35 };
36 
44 static inline struct rte_ipsec_session *
46 {
47  const struct rte_security_session *ss;
48  const struct rte_cryptodev_sym_session *cs;
49 
51  ss = cop->sym[0].sec_session;
52  return (void *)(uintptr_t)ss->opaque_data;
53  } else if (cop->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
54  cs = cop->sym[0].session;
55  return (void *)(uintptr_t)cs->opaque_data;
56  }
57  return NULL;
58 }
59 
80 static inline uint16_t
82  struct rte_mbuf *mb[], struct rte_ipsec_group grp[], uint16_t num)
83 {
84  uint32_t i, j, k, n;
85  void *ns, *ps;
86  struct rte_mbuf *m, *dr[num];
87 
88  j = 0;
89  k = 0;
90  n = 0;
91  ps = NULL;
92 
93  for (i = 0; i != num; i++) {
94 
95  m = cop[i]->sym[0].m_src;
96  ns = cop[i]->sym[0].session;
97 
99  if (cop[i]->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
101 
102  /* no valid session found */
103  if (ns == NULL) {
104  dr[k++] = m;
105  continue;
106  }
107 
108  /* different SA */
109  if (ps != ns) {
110 
111  /*
112  * we already have an open group - finalize it,
113  * then open a new one.
114  */
115  if (ps != NULL) {
116  grp[n].id.ptr =
117  rte_ipsec_ses_from_crypto(cop[i - 1]);
118  grp[n].cnt = mb + j - grp[n].m;
119  n++;
120  }
121 
122  /* start new group */
123  grp[n].m = mb + j;
124  ps = ns;
125  }
126 
127  mb[j++] = m;
128  }
129 
130  /* finalise last group */
131  if (ps != NULL) {
132  grp[n].id.ptr = rte_ipsec_ses_from_crypto(cop[i - 1]);
133  grp[n].cnt = mb + j - grp[n].m;
134  n++;
135  }
136 
137  /* copy mbufs with unknown session beyond recognised ones */
138  if (k != 0 && k != num) {
139  for (i = 0; i != k; i++)
140  mb[j + i] = dr[i];
141  }
142 
143  return n;
144 }
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 
150 #endif /* _RTE_IPSEC_GROUP_H_ */
RTE_CRYPTO_OP_SECURITY_SESSION
@ RTE_CRYPTO_OP_SECURITY_SESSION
Definition: rte_crypto.h:65
RTE_CRYPTO_OP_STATUS_SUCCESS
@ RTE_CRYPTO_OP_STATUS_SUCCESS
Definition: rte_crypto.h:40
rte_ipsec_pkt_crypto_group
static uint16_t rte_ipsec_pkt_crypto_group(const struct rte_crypto_op *cop[], struct rte_mbuf *mb[], struct rte_ipsec_group grp[], uint16_t num)
Definition: rte_ipsec_group.h:81
rte_mbuf
Definition: rte_mbuf_core.h:473
PKT_RX_SEC_OFFLOAD
#define PKT_RX_SEC_OFFLOAD
Definition: rte_mbuf_core.h:157
rte_crypto_op
Definition: rte_crypto.h:78
rte_crypto_sym_op::m_src
struct rte_mbuf * m_src
Definition: rte_crypto_sym.h:592
rte_ipsec_group
Definition: rte_ipsec_group.h:27
rte_crypto_op::sym
struct rte_crypto_sym_op sym[0]
Definition: rte_crypto.h:118
rte_ipsec_group::m
struct rte_mbuf ** m
Definition: rte_ipsec_group.h:32
RTE_CRYPTO_OP_WITH_SESSION
@ RTE_CRYPTO_OP_WITH_SESSION
Definition: rte_crypto.h:63
rte_crypto_sym_op::sec_session
struct rte_security_session * sec_session
Definition: rte_crypto_sym.h:601
rte_ipsec_group::cnt
uint32_t cnt
Definition: rte_ipsec_group.h:33
rte_mbuf::ol_flags
uint64_t ol_flags
Definition: rte_mbuf_core.h:505
rte_ipsec_session
Definition: rte_ipsec.h:58
rte_cryptodev_sym_session
Definition: rte_cryptodev.h:1002
PKT_RX_SEC_OFFLOAD_FAILED
#define PKT_RX_SEC_OFFLOAD_FAILED
Definition: rte_mbuf_core.h:162
rte_crypto_op::sess_type
uint8_t sess_type
Definition: rte_crypto.h:94
rte_ipsec_group::id
union rte_ipsec_group::@227 id
rte_crypto_sym_op::session
struct rte_cryptodev_sym_session * session
Definition: rte_crypto_sym.h:597
rte_cryptodev_sym_session::opaque_data
uint64_t opaque_data
Definition: rte_cryptodev.h:1003
rte_ipsec_group::rc
int32_t rc
Definition: rte_ipsec_group.h:34
rte_ipsec_ses_from_crypto
static struct rte_ipsec_session * rte_ipsec_ses_from_crypto(const struct rte_crypto_op *cop)
Definition: rte_ipsec_group.h:45