DPDK  20.11.3
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_ */
struct rte_mbuf ** m
struct rte_security_session * sec_session
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)
static struct rte_ipsec_session * rte_ipsec_ses_from_crypto(const struct rte_crypto_op *cop)
struct rte_mbuf * m_src
uint64_t ol_flags
struct rte_cryptodev_sym_session * session
union rte_ipsec_group::@227 id
#define PKT_RX_SEC_OFFLOAD
uint8_t sess_type
Definition: rte_crypto.h:94
#define PKT_RX_SEC_OFFLOAD_FAILED
struct rte_crypto_sym_op sym[0]
Definition: rte_crypto.h:118