X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fcrypto%2Fcnxk%2Fcnxk_cryptodev_ops.h;h=e521f07585c6103f823c9837674560d84e315535;hb=5c374e9d7442744e302eb7d349307a4d2951c9f1;hp=c317f4049aa99b37abbf0770bf97c60a255e56a4;hpb=5a3513caeb455ccf2d36a73cee5ed11b6ca64607;p=dpdk.git diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h index c317f4049a..e521f07585 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h +++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h @@ -6,31 +6,30 @@ #define _CNXK_CRYPTODEV_OPS_H_ #include +#include #include "roc_api.h" #define CNXK_CPT_MIN_HEADROOM_REQ 24 +#define CNXK_CPT_MIN_TAILROOM_REQ 102 /* Default command timeout in seconds */ #define DEFAULT_COMMAND_TIMEOUT 4 #define MOD_INC(i, l) ((i) == (l - 1) ? (i) = 0 : (i)++) +/* Macros to form words in CPT instruction */ +#define CNXK_CPT_INST_W2(tag, tt, grp, rvu_pf_func) \ + ((tag) | ((uint64_t)(tt) << 32) | ((uint64_t)(grp) << 34) | \ + ((uint64_t)(rvu_pf_func) << 48)) +#define CNXK_CPT_INST_W3(qord, wqe_ptr) \ + (qord | ((uintptr_t)(wqe_ptr) >> 3) << 3) + struct cpt_qp_meta_info { struct rte_mempool *pool; int mlen; }; -enum sym_xform_type { - CNXK_CPT_CIPHER = 1, - CNXK_CPT_AUTH, - CNXK_CPT_AEAD, - CNXK_CPT_CIPHER_ENC_AUTH_GEN, - CNXK_CPT_AUTH_VRFY_CIPHER_DEC, - CNXK_CPT_AUTH_GEN_CIPHER_ENC, - CNXK_CPT_CIPHER_DEC_AUTH_VRFY -}; - #define CPT_OP_FLAGS_METABUF (1 << 1) #define CPT_OP_FLAGS_AUTH_VERIFY (1 << 0) #define CPT_OP_FLAGS_IPSEC_DIR_INBOUND (1 << 2) @@ -40,21 +39,29 @@ struct cpt_inflight_req { struct rte_crypto_op *cop; void *mdata; uint8_t op_flags; + void *qp; } __rte_aligned(16); struct pending_queue { - /** Pending requests count */ - uint64_t pending_count; /** Array of pending requests */ struct cpt_inflight_req *req_queue; - /** Tail of queue to be used for enqueue */ - uint16_t enq_tail; - /** Head of queue to be used for dequeue */ - uint16_t deq_head; + /** Head of the queue to be used for enqueue */ + uint64_t head; + /** Tail of the queue to be used for dequeue */ + uint64_t tail; + /** Pending queue mask */ + uint64_t pq_mask; /** Timeout to track h/w being unresponsive */ uint64_t time_out; }; +struct crypto_adpter_info { + bool enabled; + /**< Set if queue pair is added to crypto adapter */ + struct rte_mempool *req_mp; + /**< CPT inflight request mempool */ +}; + struct cnxk_cpt_qp { struct roc_cpt_lf lf; /**< Crypto LF */ @@ -68,6 +75,8 @@ struct cnxk_cpt_qp { /**< Metabuf info required to support operations on the queue pair */ struct roc_cpt_lmtline lmtline; /**< Lmtline information */ + struct crypto_adpter_info ca; + /**< Crypto adapter related info */ }; int cnxk_cpt_dev_config(struct rte_cryptodev *dev, @@ -113,4 +122,53 @@ int cnxk_ae_session_cfg(struct rte_cryptodev *dev, struct rte_crypto_asym_xform *xform, struct rte_cryptodev_asym_session *sess, struct rte_mempool *pool); +void cnxk_cpt_dump_on_err(struct cnxk_cpt_qp *qp); + +static inline union rte_event_crypto_metadata * +cnxk_event_crypto_mdata_get(struct rte_crypto_op *op) +{ + union rte_event_crypto_metadata *ec_mdata; + + if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) + ec_mdata = rte_cryptodev_sym_session_get_user_data( + op->sym->session); + else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS && + op->private_data_offset) + ec_mdata = (union rte_event_crypto_metadata + *)((uint8_t *)op + op->private_data_offset); + else + return NULL; + + return ec_mdata; +} + +static __rte_always_inline void +pending_queue_advance(uint64_t *index, const uint64_t mask) +{ + *index = (*index + 1) & mask; +} + +static __rte_always_inline void +pending_queue_retreat(uint64_t *index, const uint64_t mask, uint64_t nb_entry) +{ + *index = (*index - nb_entry) & mask; +} + +static __rte_always_inline uint64_t +pending_queue_infl_cnt(uint64_t head, uint64_t tail, const uint64_t mask) +{ + /* + * Mask is nb_desc - 1. Add nb_desc to head and mask to account for + * cases when tail > head, which happens during wrap around. + */ + return ((head + mask + 1) - tail) & mask; +} + +static __rte_always_inline uint64_t +pending_queue_free_cnt(uint64_t head, uint64_t tail, const uint64_t mask) +{ + /* mask is nb_desc - 1 */ + return mask - pending_queue_infl_cnt(head, tail, mask); +} + #endif /* _CNXK_CRYPTODEV_OPS_H_ */