X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fcrypto%2Fqat%2Fqat_sym.h;h=b58be12822ad8e852f436958ecea34c42bdf621d;hb=53e6f86cf550a75fb1d55a76f411e214e783d14d;hp=dbca74efba311a84f9db577818c77e2b125d1302;hpb=21792c4432056711bfac7f08500eb50100c9122c;p=dpdk.git diff --git a/drivers/crypto/qat/qat_sym.h b/drivers/crypto/qat/qat_sym.h index dbca74efba..b58be12822 100644 --- a/drivers/crypto/qat/qat_sym.h +++ b/drivers/crypto/qat/qat_sym.h @@ -6,7 +6,7 @@ #define _QAT_SYM_H_ #include -#ifdef RTE_LIBRTE_SECURITY +#ifdef RTE_LIB_SECURITY #include #endif @@ -135,28 +135,80 @@ qat_bpicipher_postprocess(struct qat_sym_session *ctx, return sym_op->cipher.data.length - last_block_len; } -#ifdef RTE_LIBRTE_SECURITY +#ifdef RTE_LIB_SECURITY static inline void qat_crc_verify(struct qat_sym_session *ctx, struct rte_crypto_op *op) { struct rte_crypto_sym_op *sym_op = op->sym; - uint32_t crc_offset, crc_length, crc; + uint32_t crc_data_ofs, crc_data_len, crc; uint8_t *crc_data; if (ctx->qat_dir == ICP_QAT_HW_CIPHER_DECRYPT && sym_op->auth.data.length != 0) { - crc_offset = sym_op->auth.data.offset; - crc_length = sym_op->auth.data.length; + crc_data_ofs = sym_op->auth.data.offset; + crc_data_len = sym_op->auth.data.length; crc_data = rte_pktmbuf_mtod_offset(sym_op->m_src, uint8_t *, - crc_offset); + crc_data_ofs); - crc = rte_net_crc_calc(crc_data, crc_length, RTE_NET_CRC32_ETH); + crc = rte_net_crc_calc(crc_data, crc_data_len, + RTE_NET_CRC32_ETH); - if (crc != *(uint32_t *)(crc_data + crc_length)) + if (crc != *(uint32_t *)(crc_data + crc_data_len)) op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED; } } + +static inline void +qat_crc_generate(struct qat_sym_session *ctx, + struct rte_crypto_op *op) +{ + struct rte_crypto_sym_op *sym_op = op->sym; + uint32_t *crc, crc_data_len; + uint8_t *crc_data; + + if (ctx->qat_dir == ICP_QAT_HW_CIPHER_ENCRYPT && + sym_op->auth.data.length != 0 && + sym_op->m_src->nb_segs == 1) { + + crc_data_len = sym_op->auth.data.length; + crc_data = rte_pktmbuf_mtod_offset(sym_op->m_src, uint8_t *, + sym_op->auth.data.offset); + crc = (uint32_t *)(crc_data + crc_data_len); + *crc = rte_net_crc_calc(crc_data, crc_data_len, + RTE_NET_CRC32_ETH); + } +} + +static inline void +qat_sym_preprocess_requests(void **ops, uint16_t nb_ops) +{ + struct rte_crypto_op *op; + struct qat_sym_session *ctx; + uint16_t i; + + for (i = 0; i < nb_ops; i++) { + op = (struct rte_crypto_op *)ops[i]; + + if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) { + ctx = (struct qat_sym_session *) + get_sec_session_private_data( + op->sym->sec_session); + + if (ctx == NULL || ctx->bpi_ctx == NULL) + continue; + + qat_crc_generate(ctx, op); + } + } +} +#else + +static inline void +qat_sym_preprocess_requests(void **ops __rte_unused, + uint16_t nb_ops __rte_unused) +{ +} #endif static inline void @@ -179,7 +231,7 @@ qat_sym_process_response(void **op, uint8_t *resp) rx_op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED; } else { -#ifdef RTE_LIBRTE_SECURITY +#ifdef RTE_LIB_SECURITY uint8_t is_docsis_sec = 0; if (rx_op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) { @@ -204,7 +256,7 @@ qat_sym_process_response(void **op, uint8_t *resp) if (sess->bpi_ctx) { qat_bpicipher_postprocess(sess, rx_op); -#ifdef RTE_LIBRTE_SECURITY +#ifdef RTE_LIB_SECURITY if (is_docsis_sec) qat_crc_verify(sess, rx_op); #endif @@ -212,11 +264,28 @@ qat_sym_process_response(void **op, uint8_t *resp) } *op = (void *)rx_op; } + +int +qat_sym_configure_dp_ctx(struct rte_cryptodev *dev, uint16_t qp_id, + struct rte_crypto_raw_dp_ctx *raw_dp_ctx, + enum rte_crypto_op_sess_type sess_type, + union rte_cryptodev_session_ctx session_ctx, uint8_t is_update); + +int +qat_sym_get_dp_ctx_size(struct rte_cryptodev *dev); + #else +static inline void +qat_sym_preprocess_requests(void **ops __rte_unused, + uint16_t nb_ops __rte_unused) +{ +} + static inline void qat_sym_process_response(void **op __rte_unused, uint8_t *resp __rte_unused) { } + #endif #endif /* _QAT_SYM_H_ */