From: Anoob Joseph <anoobj@marvell.com>
Use opaque pointer instead of void * for PMD APIs. Usage of forward
declaration and opaque pointer would allow compiler to prevent
unintended usage which cannot be prevented with void *.
Signed-off-by: Anoob Joseph <anoobj@marvell.com>
---
drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 12 ++++++------
drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h | 18 +++++++++++++++---
2 files changed, 21 insertions(+), 9 deletions(-)
@@ -945,7 +945,7 @@ cnxk_cpt_queue_pair_event_error_query(struct rte_cryptodev *dev, uint16_t qp_id)
return 0;
}
-void *
+struct rte_pmd_cnxk_crypto_qptr *
rte_pmd_cnxk_crypto_qptr_get(uint8_t dev_id, uint16_t qp_id)
{
const struct rte_crypto_fp_ops *fp_ops;
@@ -958,9 +958,9 @@ rte_pmd_cnxk_crypto_qptr_get(uint8_t dev_id, uint16_t qp_id)
}
static inline void
-cnxk_crypto_cn10k_submit(void *qptr, void *inst, uint16_t nb_inst)
+cnxk_crypto_cn10k_submit(struct rte_pmd_cnxk_crypto_qptr *qptr, void *inst, uint16_t nb_inst)
{
- struct cnxk_cpt_qp *qp = qptr;
+ struct cnxk_cpt_qp *qp = PLT_PTR_CAST(qptr);
uint64_t lmt_base, io_addr;
uint16_t lmt_id;
void *lmt_dst;
@@ -987,9 +987,9 @@ cnxk_crypto_cn10k_submit(void *qptr, void *inst, uint16_t nb_inst)
}
static inline void
-cnxk_crypto_cn9k_submit(void *qptr, void *inst, uint16_t nb_inst)
+cnxk_crypto_cn9k_submit(struct rte_pmd_cnxk_crypto_qptr *qptr, void *inst, uint16_t nb_inst)
{
- struct cnxk_cpt_qp *qp = qptr;
+ struct cnxk_cpt_qp *qp = PLT_PTR_CAST(qptr);
const uint64_t lmt_base = qp->lf.lmt_base;
const uint64_t io_addr = qp->lf.io_addr;
@@ -1008,7 +1008,7 @@ cnxk_crypto_cn9k_submit(void *qptr, void *inst, uint16_t nb_inst)
}
void
-rte_pmd_cnxk_crypto_submit(void *qptr, void *inst, uint16_t nb_inst)
+rte_pmd_cnxk_crypto_submit(struct rte_pmd_cnxk_crypto_qptr *qptr, void *inst, uint16_t nb_inst)
{
if (roc_model_is_cn10k())
return cnxk_crypto_cn10k_submit(qptr, inst, nb_inst);
@@ -13,6 +13,16 @@
#include <stdint.h>
+/* Forward declarations */
+
+/**
+ * @brief Crypto CNXK PMD QPTR opaque pointer.
+ *
+ * This structure represents the queue pair structure that would be the input to APIs that use
+ * hardware queues.
+ */
+struct rte_pmd_cnxk_crypto_qptr;
+
/**
* Get queue pointer of a specific queue in a cryptodev.
*
@@ -21,10 +31,11 @@
* @param qp_id
* Index of the queue pair.
* @return
- * Pointer to queue pair structure that would be the input to submit APIs.
+ * - On success, pointer to queue pair structure that would be the input to submit APIs.
+ * - NULL on error.
*/
__rte_experimental
-void *rte_pmd_cnxk_crypto_qptr_get(uint8_t dev_id, uint16_t qp_id);
+struct rte_pmd_cnxk_crypto_qptr *rte_pmd_cnxk_crypto_qptr_get(uint8_t dev_id, uint16_t qp_id);
/**
* Submit CPT instruction (cpt_inst_s) to hardware (CPT).
@@ -43,6 +54,7 @@ void *rte_pmd_cnxk_crypto_qptr_get(uint8_t dev_id, uint16_t qp_id);
* Number of instructions.
*/
__rte_experimental
-void rte_pmd_cnxk_crypto_submit(void *qptr, void *inst, uint16_t nb_inst);
+void rte_pmd_cnxk_crypto_submit(struct rte_pmd_cnxk_crypto_qptr *qptr, void *inst,
+ uint16_t nb_inst);
#endif /* _PMD_CNXK_CRYPTO_H_ */