From: Anoob Joseph <ano...@marvell.com> Add PMD API to get CPT LF(QP) stats.
Signed-off-by: Anoob Joseph <ano...@marvell.com> --- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 32 +++++++++++++++++++++ drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h | 34 +++++++++++++++++++++++ drivers/crypto/cnxk/version.map | 1 + 3 files changed, 67 insertions(+) diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c index a7d58a5445..2355bc3737 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c @@ -1161,3 +1161,35 @@ rte_pmd_cnxk_crypto_cptr_write(struct rte_pmd_cnxk_crypto_qptr *qptr, return 0; } + +int +rte_pmd_cnxk_crypto_qp_stats_get(struct rte_pmd_cnxk_crypto_qptr *qptr, + struct rte_pmd_cnxk_crypto_qp_stats *stats) +{ + struct cnxk_cpt_qp *qp = PLT_PTR_CAST(qptr); + struct roc_cpt_lf *lf; + + if (unlikely(qptr == NULL)) { + plt_err("Invalid queue pair pointer"); + return -EINVAL; + } + + if (unlikely(stats == NULL)) { + plt_err("Invalid stats pointer"); + return -EINVAL; + } + + if (unlikely(roc_model_is_cn9k())) { + plt_err("Invalid cnxk model"); + return -EINVAL; + } + + lf = &qp->lf; + + stats->ctx_enc_pkts = plt_read64(lf->rbase + CPT_LF_CTX_ENC_PKT_CNT); + stats->ctx_enc_bytes = plt_read64(lf->rbase + CPT_LF_CTX_ENC_BYTE_CNT); + stats->ctx_dec_bytes = plt_read64(lf->rbase + CPT_LF_CTX_DEC_BYTE_CNT); + stats->ctx_dec_bytes = plt_read64(lf->rbase + CPT_LF_CTX_DEC_BYTE_CNT); + + return 0; +} diff --git a/drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h b/drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h index 454261022b..02278605a2 100644 --- a/drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h +++ b/drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h @@ -30,6 +30,23 @@ struct rte_pmd_cnxk_crypto_qptr; */ struct rte_pmd_cnxk_crypto_cptr; +/** + * + * @brief Crypto CNXK queue pair stats. + * + * This structure represents the queue pair stats retrieved from CPT HW queue. + */ +struct rte_pmd_cnxk_crypto_qp_stats { + /** Packet counter of the packets that used CPT context cache and was encrypted */ + uint64_t ctx_enc_pkts; + /** Byte counter of the packets that used CPT context cache and was encrypted */ + uint64_t ctx_enc_bytes; + /** Packet counter of the packets that used CPT context cache and was decrypted */ + uint64_t ctx_dec_pkts; + /** Byte counter of the packets that used CPT context cache and was decrypted */ + uint64_t ctx_dec_bytes; +}; + /** * @brief Crypto CNXK PMD session structure. * @@ -176,4 +193,21 @@ int rte_pmd_cnxk_crypto_cptr_write(struct rte_pmd_cnxk_crypto_qptr *qptr, struct rte_pmd_cnxk_crypto_cptr *cptr, void *data, uint32_t len); +/** + * Get the HW Queue Pair (LF) stats. + * + * @param qptr + * Pointer obtained with ``rte_pmd_cnxk_crypto_qptr_get``. + * @param[out] stats + * Pointer to the structure where stats will be copied. + * + * @return + * - 0 On success. + * - Negative value on error. + * - -EINVAL if the input parameters are invalid. + */ +__rte_experimental +int rte_pmd_cnxk_crypto_qp_stats_get(struct rte_pmd_cnxk_crypto_qptr *qptr, + struct rte_pmd_cnxk_crypto_qp_stats *stats); + #endif /* _PMD_CNXK_CRYPTO_H_ */ diff --git a/drivers/crypto/cnxk/version.map b/drivers/crypto/cnxk/version.map index 6e51f7be1a..05724e69e4 100644 --- a/drivers/crypto/cnxk/version.map +++ b/drivers/crypto/cnxk/version.map @@ -10,6 +10,7 @@ EXPERIMENTAL { rte_pmd_cnxk_crypto_cptr_get; rte_pmd_cnxk_crypto_cptr_read; rte_pmd_cnxk_crypto_cptr_write; + rte_pmd_cnxk_crypto_qp_stats_get; }; INTERNAL { -- 2.25.1