X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_ipsec%2Fcrypto.h;h=3d03034590caf81de11be00c50e401e492b85e31;hb=c5a4428a783d173721ad0ed5486d058976737af8;hp=b5f2648318b0cc7fb1b8c20825d34e2d9adddeb4;hpb=423aa5e130baa4570bbb8b2035b7af292dcc1daf;p=dpdk.git diff --git a/lib/librte_ipsec/crypto.h b/lib/librte_ipsec/crypto.h index b5f2648318..3d03034590 100644 --- a/lib/librte_ipsec/crypto.h +++ b/lib/librte_ipsec/crypto.h @@ -11,6 +11,16 @@ * by ipsec library. */ +/* + * AES-CTR counter block format. + */ + +struct aesctr_cnt_blk { + uint32_t nonce; + uint64_t iv; + uint32_t cnt; +} __rte_packed; + /* * AES-GCM devices have some specific requirements for IV and AAD formats. * Ideally that to be done by the driver itself. @@ -20,7 +30,7 @@ struct aead_gcm_iv { uint32_t salt; uint64_t iv; uint32_t cnt; -} __attribute__((packed)); +} __rte_packed; struct aead_gcm_aad { uint32_t spi; @@ -34,13 +44,20 @@ struct aead_gcm_aad { uint64_t u64; } sqn; uint32_t align0; /* align to 16B boundary */ -} __attribute__((packed)); +} __rte_packed; struct gcm_esph_iv { - struct esp_hdr esph; + struct rte_esp_hdr esph; uint64_t iv; -} __attribute__((packed)); +} __rte_packed; +static inline void +aes_ctr_cnt_blk_fill(struct aesctr_cnt_blk *ctr, uint64_t iv, uint32_t nonce) +{ + ctr->nonce = nonce; + ctr->iv = iv; + ctr->cnt = rte_cpu_to_be_32(1); +} static inline void aead_gcm_iv_fill(struct aead_gcm_iv *gcm, uint64_t iv, uint32_t salt) @@ -78,7 +95,7 @@ gen_iv(uint64_t iv[IPSEC_MAX_IV_QWORD], rte_be64_t sqn) /* * Helper routine to copy IV - * Righ now we support only algorithms with IV length equals 0/8/16 bytes. + * Right now we support only algorithms with IV length equals 0/8/16 bytes. */ static inline void copy_iv(uint64_t dst[IPSEC_MAX_IV_QWORD], @@ -145,4 +162,21 @@ remove_sqh(void *picv, uint32_t icv_len) icv[i] = icv[i + 1]; } +/* + * setup crypto ops for LOOKASIDE_NONE (pure crypto) type of devices. + */ +static inline void +lksd_none_cop_prepare(struct rte_crypto_op *cop, + struct rte_cryptodev_sym_session *cs, struct rte_mbuf *mb) +{ + struct rte_crypto_sym_op *sop; + + sop = cop->sym; + cop->type = RTE_CRYPTO_OP_TYPE_SYMMETRIC; + cop->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; + cop->sess_type = RTE_CRYPTO_OP_WITH_SESSION; + sop->m_src = mb; + __rte_crypto_sym_op_attach_sym_session(sop, cs); +} + #endif /* _CRYPTO_H_ */