From: Tejasree Kondoj <kondoj.tejas...@caviumnetworks.com>

Signed-off-by: Ankur Dwivedi <ankur.dwiv...@caviumnetworks.com>
Signed-off-by: Anoob Joseph <anoob.jos...@caviumnetworks.com>
Signed-off-by: Murthy NSSR <nidadavolu.mur...@caviumnetworks.com>
Signed-off-by: Nithin Dabilpuram <nithin.dabilpu...@caviumnetworks.com>
Signed-off-by: Ragothaman Jayaraman <rjayara...@caviumnetworks.com>
Signed-off-by: Srisivasubramanian S <ssriniva...@caviumnetworks.com>
Signed-off-by: Tejasree Kondoj <kondoj.tejas...@caviumnetworks.com>
---
 drivers/common/cpt/cpt_common.h        |  1 +
 drivers/common/cpt/cpt_mcode_defines.h | 15 +++++++++++++
 drivers/common/cpt/cpt_request_mgr.h   | 39 ++++++++++++++++++++++++++++++++++
 drivers/common/cpt/cpt_ucode.h         | 26 +++++++++++++++++++++++
 4 files changed, 81 insertions(+)

diff --git a/drivers/common/cpt/cpt_common.h b/drivers/common/cpt/cpt_common.h
index 6debf42..a9e179a 100644
--- a/drivers/common/cpt/cpt_common.h
+++ b/drivers/common/cpt/cpt_common.h
@@ -15,6 +15,7 @@
  */
 #define CRYPTO_OCTEONTX                0x1
 
+#define TIME_IN_RESET_COUNT    5
 
 /* Default command timeout in seconds */
 #define DEFAULT_COMMAND_TIMEOUT        4
diff --git a/drivers/common/cpt/cpt_mcode_defines.h 
b/drivers/common/cpt/cpt_mcode_defines.h
index b580289..3b64698 100644
--- a/drivers/common/cpt/cpt_mcode_defines.h
+++ b/drivers/common/cpt/cpt_mcode_defines.h
@@ -176,6 +176,21 @@ typedef enum {
        ERR_ENODEV,
 } mc_error_code_t;
 
+/**
+ * Enumeration cpt_comp_e
+ *
+ * CPT Completion Enumeration
+ * Enumerates the values of CPT_RES_S[COMPCODE].
+ */
+typedef enum {
+       CPT_8X_COMP_E_NOTDONE    = (0x00),
+       CPT_8X_COMP_E_GOOD       = (0x01),
+       CPT_8X_COMP_E_FAULT      = (0x02),
+       CPT_8X_COMP_E_SWERR      = (0x03),
+       CPT_8X_COMP_E_HWERR      = (0x04),
+       CPT_8X_COMP_E_LAST_ENTRY = (0xFF)
+} cpt_comp_e_t;
+
 typedef struct sglist_comp {
        union {
                uint64_t len;
diff --git a/drivers/common/cpt/cpt_request_mgr.h 
b/drivers/common/cpt/cpt_request_mgr.h
index 4bf8de3..fb11c4f 100644
--- a/drivers/common/cpt/cpt_request_mgr.h
+++ b/drivers/common/cpt/cpt_request_mgr.h
@@ -147,4 +147,43 @@ cpt_pmd_crypto_operation(struct cpt_instance *instance,
        return ret;
 }
 
+static __rte_always_inline int32_t __hot
+cpt_dequeue_burst(struct cpt_instance *instance, uint16_t cnt,
+                 void *resp[], uint8_t cc[], struct pending_queue *pqueue)
+{
+       struct cpt_request_info *user_req;
+       struct rid *rid_e;
+       int i, count, pcount;
+       uint8_t ret;
+
+       pcount = pqueue->pending_count;
+       count = (cnt > pcount) ? pcount : cnt;
+
+       for (i = 0; i < count; i++) {
+               rid_e = &pqueue->rid_queue[pqueue->deq_head];
+               user_req = (struct cpt_request_info *)(rid_e->rid);
+
+               if (likely((i+1) < count))
+                       rte_prefetch_non_temporal((void *)rid_e[1].rid);
+
+               ret = check_nb_command_id(user_req, instance);
+
+               if (unlikely(ret == ERR_REQ_PENDING)) {
+                       /* Stop checking for completions */
+                       break;
+               }
+
+               /* Return completion code and op handle */
+               cc[i] = (uint8_t)ret;
+               resp[i] = user_req->op;
+               CPT_LOG_DP_DEBUG("Request %p Op %p completed with code %d",
+                          user_req, user_req->op, ret);
+
+               MOD_INC(pqueue->deq_head, DEFAULT_CMD_QLEN);
+               pqueue->pending_count -= 1;
+       }
+
+       return i;
+}
+
 #endif /* _CPT_REQUEST_MGR_H_ */
diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h
index 7d2b3ef..eff71c9 100644
--- a/drivers/common/cpt/cpt_ucode.h
+++ b/drivers/common/cpt/cpt_ucode.h
@@ -3366,6 +3366,32 @@ fill_fc_params(struct rte_crypto_op *cop,
        return prep_req;
 }
 
+static __rte_always_inline void
+compl_auth_verify(struct rte_crypto_op *op,
+                     uint8_t *gen_mac,
+                     uint64_t mac_len)
+{
+       uint8_t *mac;
+       struct rte_crypto_sym_op *sym_op = op->sym;
+
+       if (sym_op->auth.digest.data)
+               mac = sym_op->auth.digest.data;
+       else
+               mac = rte_pktmbuf_mtod_offset(sym_op->m_src,
+                                             uint8_t *,
+                                             sym_op->auth.data.length +
+                                             sym_op->auth.data.offset);
+       if (!mac) {
+               op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+               return;
+       }
+
+       if (memcmp(mac, gen_mac, mac_len))
+               op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
+       else
+               op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+}
+
 static __rte_always_inline int
 instance_session_cfg(struct rte_crypto_sym_xform *xform, void *sess)
 {
-- 
2.7.4

Reply via email to