MCPcopy Create free account
hub / github.com/F-Stack/f-stack / inb_cop_prepare

Function inb_cop_prepare

dpdk/lib/ipsec/esp_inb.c:58–133  ·  view source on GitHub ↗

* setup crypto op and crypto sym op for ESP inbound packet. */

Source from the content-addressed store, hash-verified

56 * setup crypto op and crypto sym op for ESP inbound packet.
57 */
58static inline void
59inb_cop_prepare(struct rte_crypto_op *cop,
60 const struct rte_ipsec_sa *sa, struct rte_mbuf *mb,
61 const union sym_op_data *icv, uint32_t pofs, uint32_t plen)
62{
63 struct rte_crypto_sym_op *sop;
64 struct aead_gcm_iv *gcm;
65 struct aead_ccm_iv *ccm;
66 struct aead_chacha20_poly1305_iv *chacha20_poly1305;
67 struct aesctr_cnt_blk *ctr;
68 uint64_t *ivc, *ivp;
69 uint32_t algo;
70
71 algo = sa->algo_type;
72 ivp = rte_pktmbuf_mtod_offset(mb, uint64_t *,
73 pofs + sizeof(struct rte_esp_hdr));
74
75 /* fill sym op fields */
76 sop = cop->sym;
77
78 switch (algo) {
79 case ALGO_TYPE_AES_GCM:
80 sop_aead_prepare(sop, sa, icv, pofs, plen);
81
82 /* fill AAD IV (located inside crypto op) */
83 gcm = rte_crypto_op_ctod_offset(cop, struct aead_gcm_iv *,
84 sa->iv_ofs);
85 aead_gcm_iv_fill(gcm, ivp[0], sa->salt);
86 break;
87 case ALGO_TYPE_AES_CCM:
88 sop_aead_prepare(sop, sa, icv, pofs, plen);
89
90 /* fill AAD IV (located inside crypto op) */
91 ccm = rte_crypto_op_ctod_offset(cop, struct aead_ccm_iv *,
92 sa->iv_ofs);
93 aead_ccm_iv_fill(ccm, ivp[0], sa->salt);
94 break;
95 case ALGO_TYPE_CHACHA20_POLY1305:
96 sop_aead_prepare(sop, sa, icv, pofs, plen);
97
98 /* fill AAD IV (located inside crypto op) */
99 chacha20_poly1305 = rte_crypto_op_ctod_offset(cop,
100 struct aead_chacha20_poly1305_iv *,
101 sa->iv_ofs);
102 aead_chacha20_poly1305_iv_fill(chacha20_poly1305,
103 ivp[0], sa->salt);
104 break;
105 case ALGO_TYPE_AES_CBC:
106 case ALGO_TYPE_3DES_CBC:
107 sop_ciph_auth_prepare(sop, sa, icv, pofs, plen);
108
109 /* copy iv from the input packet to the cop */
110 ivc = rte_crypto_op_ctod_offset(cop, uint64_t *, sa->iv_ofs);
111 copy_iv(ivc, ivp, sa->iv_len);
112 break;
113 case ALGO_TYPE_AES_GMAC:
114 sop_ciph_auth_prepare(sop, sa, icv, pofs, plen);
115

Callers 1

esp_inb_pkt_prepareFunction · 0.85

Calls 7

aead_gcm_iv_fillFunction · 0.85
aead_ccm_iv_fillFunction · 0.85
copy_ivFunction · 0.85
aes_ctr_cnt_blk_fillFunction · 0.85
sop_aead_prepareFunction · 0.70
sop_ciph_auth_prepareFunction · 0.70

Tested by

no test coverage detected