DPDK  19.11.1
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 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
29  union {
30  uint64_t val;
31  void *ptr;
32  } id;
33  struct rte_mbuf **m;
34  uint32_t cnt;
35  int32_t rc;
36 };
37 
45 __rte_experimental
46 static inline struct rte_ipsec_session *
48 {
49  const struct rte_security_session *ss;
50  const struct rte_cryptodev_sym_session *cs;
51 
53  ss = cop->sym[0].sec_session;
54  return (void *)(uintptr_t)ss->opaque_data;
55  } else if (cop->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
56  cs = cop->sym[0].session;
57  return (void *)(uintptr_t)cs->opaque_data;
58  }
59  return NULL;
60 }
61 
82 __rte_experimental
83 static inline uint16_t
85  struct rte_mbuf *mb[], struct rte_ipsec_group grp[], uint16_t num)
86 {
87  uint32_t i, j, k, n;
88  void *ns, *ps;
89  struct rte_mbuf *m, *dr[num];
90 
91  j = 0;
92  k = 0;
93  n = 0;
94  ps = NULL;
95 
96  for (i = 0; i != num; i++) {
97 
98  m = cop[i]->sym[0].m_src;
99  ns = cop[i]->sym[0].session;
100 
102  if (cop[i]->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
104 
105  /* no valid session found */
106  if (ns == NULL) {
107  dr[k++] = m;
108  continue;
109  }
110 
111  /* different SA */
112  if (ps != ns) {
113 
114  /*
115  * we already have an open group - finalize it,
116  * then open a new one.
117  */
118  if (ps != NULL) {
119  grp[n].id.ptr =
120  rte_ipsec_ses_from_crypto(cop[i - 1]);
121  grp[n].cnt = mb + j - grp[n].m;
122  n++;
123  }
124 
125  /* start new group */
126  grp[n].m = mb + j;
127  ps = ns;
128  }
129 
130  mb[j++] = m;
131  }
132 
133  /* finalise last group */
134  if (ps != NULL) {
135  grp[n].id.ptr = rte_ipsec_ses_from_crypto(cop[i - 1]);
136  grp[n].cnt = mb + j - grp[n].m;
137  n++;
138  }
139 
140  /* copy mbufs with unknown session beyond recognised ones */
141  if (k != 0 && k != num) {
142  for (i = 0; i != k; i++)
143  mb[j + i] = dr[i];
144  }
145 
146  return n;
147 }
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 #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_group::id
union rte_ipsec_group::@200 id
rte_ipsec_ses_from_crypto
static __rte_experimental struct rte_ipsec_session * rte_ipsec_ses_from_crypto(const struct rte_crypto_op *cop)
Definition: rte_ipsec_group.h:47
rte_mbuf
Definition: rte_mbuf_core.h:480
PKT_RX_SEC_OFFLOAD
#define PKT_RX_SEC_OFFLOAD
Definition: rte_mbuf_core.h:151
rte_crypto_op
Definition: rte_crypto.h:78
rte_crypto_sym_op::m_src
struct rte_mbuf * m_src
Definition: rte_crypto_sym.h:489
rte_ipsec_group
Definition: rte_ipsec_group.h:28
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:33
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:498
rte_ipsec_group::cnt
uint32_t cnt
Definition: rte_ipsec_group.h:34
rte_ipsec_pkt_crypto_group
static __rte_experimental 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:84
rte_mbuf::ol_flags
uint64_t ol_flags
Definition: rte_mbuf_core.h:522
rte_ipsec_session
Definition: rte_ipsec.h:53
rte_cryptodev_sym_session
Definition: rte_cryptodev.h:974
PKT_RX_SEC_OFFLOAD_FAILED
#define PKT_RX_SEC_OFFLOAD_FAILED
Definition: rte_mbuf_core.h:156
rte_crypto_op::sess_type
uint8_t sess_type
Definition: rte_crypto.h:94
rte_crypto_sym_op::session
struct rte_cryptodev_sym_session * session
Definition: rte_crypto_sym.h:494
rte_cryptodev_sym_session::opaque_data
uint64_t opaque_data
Definition: rte_cryptodev.h:975
rte_ipsec_group::rc
int32_t rc
Definition: rte_ipsec_group.h:35