DPDK  24.11.0-rc3
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  void *ses;
48 
50  ses = cop->sym[0].session;
51  return (struct rte_ipsec_session *)(uintptr_t)
53  } else if (cop->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
54  ses = cop->sym[0].session;
55  return (struct rte_ipsec_session *)(uintptr_t)
57  }
58  return NULL;
59 }
60 
81 static inline uint16_t
83  struct rte_mbuf *mb[], struct rte_ipsec_group grp[], uint16_t num)
84 {
85  uint32_t i, j, k, n;
86  void *ns, *ps;
87  struct rte_mbuf *m, *dr[num];
88 
89  j = 0;
90  k = 0;
91  n = 0;
92  ps = NULL;
93 
94  for (i = 0; i != num; i++) {
95 
96  m = cop[i]->sym[0].m_src;
97  ns = cop[i]->sym[0].session;
98 
100  if (cop[i]->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
102 
103  /* no valid session found */
104  if (ns == NULL) {
105  dr[k++] = m;
106  continue;
107  }
108 
109  /* different SA */
110  if (ps != ns) {
111 
112  /*
113  * we already have an open group - finalize it,
114  * then open a new one.
115  */
116  if (ps != NULL) {
117  grp[n].id.ptr =
118  rte_ipsec_ses_from_crypto(cop[i - 1]);
119  grp[n].cnt = mb + j - grp[n].m;
120  n++;
121  }
122 
123  /* start new group */
124  grp[n].m = mb + j;
125  ps = ns;
126  }
127 
128  mb[j++] = m;
129  }
130 
131  /* finalise last group */
132  if (ps != NULL) {
133  grp[n].id.ptr = rte_ipsec_ses_from_crypto(cop[i - 1]);
134  grp[n].cnt = mb + j - grp[n].m;
135  n++;
136  }
137 
138  /* copy mbufs with unknown session beyond recognised ones */
139  if (k != 0 && k != num) {
140  for (i = 0; i != k; i++)
141  mb[j + i] = dr[i];
142  }
143 
144  return n;
145 }
146 
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif /* _RTE_IPSEC_GROUP_H_ */
struct rte_mbuf ** m
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)
static uint64_t rte_security_session_opaque_data_get(void *sess)
struct rte_mbuf * m_src
#define RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED
union rte_ipsec_group::@278 id
uint64_t ol_flags
#define RTE_MBUF_F_RX_SEC_OFFLOAD
static uint64_t rte_cryptodev_sym_session_opaque_data_get(void *sess)
uint8_t sess_type
Definition: rte_crypto.h:107
struct rte_crypto_sym_op sym[0]
Definition: rte_crypto.h:178