DPDK
25.11.0
Toggle main menu visibility
Loading...
Searching...
No Matches
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
17
18
19
#ifdef __cplusplus
20
extern
"C"
{
21
#endif
22
27
struct
rte_ipsec_group
{
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
*
45
rte_ipsec_ses_from_crypto
(
const
struct
rte_crypto_op
*cop)
46
{
47
void
*ses;
48
49
if
(cop->
sess_type
==
RTE_CRYPTO_OP_SECURITY_SESSION
) {
50
ses = cop->
sym
[0].
session
;
51
return
(
struct
rte_ipsec_session
*)(uintptr_t)
52
rte_security_session_opaque_data_get
(ses);
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)
56
rte_cryptodev_sym_session_opaque_data_get
(ses);
57
}
58
return
NULL;
59
}
60
81
static
inline
uint16_t
82
rte_ipsec_pkt_crypto_group
(
const
struct
rte_crypto_op
*cop[],
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
99
m->
ol_flags
|=
RTE_MBUF_F_RX_SEC_OFFLOAD
;
100
if
(cop[i]->status !=
RTE_CRYPTO_OP_STATUS_SUCCESS
)
101
m->
ol_flags
|=
RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED
;
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_ */
RTE_CRYPTO_OP_SECURITY_SESSION
@ RTE_CRYPTO_OP_SECURITY_SESSION
Definition
rte_crypto.h:64
RTE_CRYPTO_OP_WITH_SESSION
@ RTE_CRYPTO_OP_WITH_SESSION
Definition
rte_crypto.h:62
RTE_CRYPTO_OP_STATUS_SUCCESS
@ RTE_CRYPTO_OP_STATUS_SUCCESS
Definition
rte_crypto.h:39
rte_cryptodev_sym_session_opaque_data_get
static uint64_t rte_cryptodev_sym_session_opaque_data_get(void *sess)
Definition
rte_cryptodev.h:1310
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:82
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
RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED
#define RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED
Definition
rte_mbuf_core.h:149
RTE_MBUF_F_RX_SEC_OFFLOAD
#define RTE_MBUF_F_RX_SEC_OFFLOAD
Definition
rte_mbuf_core.h:144
rte_security_session_opaque_data_get
static uint64_t rte_security_session_opaque_data_get(void *sess)
Definition
rte_security.h:1000
rte_crypto_op
Definition
rte_crypto.h:91
rte_crypto_op::sym
struct rte_crypto_sym_op sym[0]
Definition
rte_crypto.h:178
rte_crypto_op::sess_type
uint8_t sess_type
Definition
rte_crypto.h:107
rte_crypto_sym_op::session
void * session
Definition
rte_crypto_sym.h:633
rte_crypto_sym_op::m_src
struct rte_mbuf * m_src
Definition
rte_crypto_sym.h:629
rte_ipsec_group
Definition
rte_ipsec_group.h:27
rte_ipsec_group::m
struct rte_mbuf ** m
Definition
rte_ipsec_group.h:32
rte_ipsec_group::id
union rte_ipsec_group::@153111306234233376142117225376111054077361272114 id
rte_ipsec_group::cnt
uint32_t cnt
Definition
rte_ipsec_group.h:33
rte_ipsec_group::rc
int32_t rc
Definition
rte_ipsec_group.h:34
rte_ipsec_session
Definition
rte_ipsec.h:78
rte_mbuf
Definition
rte_mbuf_core.h:475
rte_mbuf::ol_flags
uint64_t ol_flags
Definition
rte_mbuf_core.h:529
lib
ipsec
rte_ipsec_group.h
Generated by
1.17.0