common/cpt: add PMD ops helper functions
authorAnoob Joseph <anoob.joseph@caviumnetworks.com>
Tue, 9 Oct 2018 09:07:38 +0000 (14:37 +0530)
committerAkhil Goyal <akhil.goyal@nxp.com>
Wed, 17 Oct 2018 10:20:06 +0000 (12:20 +0200)
Adding pmd ops helper functions. Control path accessed APIs would be
added as helper functions. Adding microcode defined macros etc as
dependencies to the helper functions.

Signed-off-by: Ankur Dwivedi <ankur.dwivedi@caviumnetworks.com>
Signed-off-by: Anoob Joseph <anoob.joseph@caviumnetworks.com>
Signed-off-by: Murthy NSSR <nidadavolu.murthy@caviumnetworks.com>
Signed-off-by: Nithin Dabilpuram <nithin.dabilpuram@caviumnetworks.com>
Signed-off-by: Ragothaman Jayaraman <rjayaraman@caviumnetworks.com>
Signed-off-by: Srisivasubramanian S <ssrinivasan@caviumnetworks.com>
Signed-off-by: Tejasree Kondoj <kondoj.tejasree@caviumnetworks.com>
drivers/common/Makefile
drivers/common/cpt/Makefile [new file with mode: 0644]
drivers/common/cpt/cpt_common.h
drivers/common/cpt/cpt_mcode_defines.h [new file with mode: 0644]
drivers/common/cpt/cpt_pmd_ops_helper.c [new file with mode: 0644]
drivers/common/cpt/cpt_pmd_ops_helper.h [new file with mode: 0644]
drivers/common/cpt/meson.build [new file with mode: 0644]
drivers/common/cpt/rte_common_cpt_version.map [new file with mode: 0644]
drivers/common/meson.build
mk/rte.app.mk

index cd465cf..87b8a59 100644 (file)
@@ -4,6 +4,10 @@
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO),y)
+DIRS-y += cpt
+endif
+
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF)$(CONFIG_RTE_LIBRTE_OCTEONTX_MEMPOOL),yy)
 DIRS-y += octeontx
 endif
diff --git a/drivers/common/cpt/Makefile b/drivers/common/cpt/Makefile
new file mode 100644 (file)
index 0000000..2340aa9
--- /dev/null
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Cavium, Inc
+#
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_common_cpt.a
+
+CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -I$(RTE_SDK)/drivers/bus/pci
+EXPORT_MAP := rte_common_cpt_version.map
+
+LIBABIVER := 1
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-y += cpt_pmd_ops_helper.c
+
+LDLIBS += -lrte_eal
+
+include $(RTE_SDK)/mk/rte.lib.mk
index 5e2099a..88f4902 100644 (file)
 #define AE_TYPE 1
 #define SE_TYPE 2
 
+#ifndef ROUNDUP4
+#define ROUNDUP4(val)  (((val) + 3) & 0xfffffffc)
+#endif
+
+#ifndef ROUNDUP8
+#define ROUNDUP8(val)  (((val) + 7) & 0xfffffff8)
+#endif
+
+#ifndef ROUNDUP16
+#define ROUNDUP16(val) (((val) + 15) & 0xfffffff0)
+#endif
+
+#ifndef __hot
+#define __hot __attribute__((hot))
+#endif
+
+#define MOD_INC(i, l)   ((i) == (l - 1) ? (i) = 0 : (i)++)
+
 struct cptvf_meta_info {
        void *cptvf_meta_pool;
        int cptvf_op_mlen;
@@ -44,4 +62,22 @@ struct pending_queue {
        uint64_t pending_count;
 };
 
+struct cpt_request_info {
+       /** Data path fields */
+       uint64_t comp_baddr;
+       volatile uint64_t *completion_addr;
+       volatile uint64_t *alternate_caddr;
+       void *op;
+       struct {
+               uint64_t ei0;
+               uint64_t ei1;
+               uint64_t ei2;
+               uint64_t ei3;
+       } ist;
+
+       /** Control path fields */
+       uint64_t time_out;
+       uint8_t extra_time;
+};
+
 #endif /* _CPT_COMMON_H_ */
diff --git a/drivers/common/cpt/cpt_mcode_defines.h b/drivers/common/cpt/cpt_mcode_defines.h
new file mode 100644 (file)
index 0000000..83a8a42
--- /dev/null
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Cavium, Inc
+ */
+
+#ifndef _CPT_MCODE_DEFINES_H_
+#define _CPT_MCODE_DEFINES_H_
+
+/*
+ * This file defines macros and structures according to microcode spec
+ *
+ */
+
+#define CPT_BYTE_16            16
+#define CPT_BYTE_24            24
+#define CPT_BYTE_32            32
+#define CPT_MAX_SG_IN_OUT_CNT  32
+#define CPT_MAX_SG_CNT         (CPT_MAX_SG_IN_OUT_CNT/2)
+
+#define COMPLETION_CODE_SIZE   8
+#define COMPLETION_CODE_INIT   0
+
+#define SG_LIST_HDR_SIZE       (8u)
+#define SG_ENTRY_SIZE          sizeof(sg_comp_t)
+
+/* #define CPT_ALWAYS_USE_SG_MODE */
+#define CPT_ALWAYS_USE_SEPARATE_BUF
+
+typedef struct sglist_comp {
+       union {
+               uint64_t len;
+               struct {
+                       uint16_t len[4];
+               } s;
+       } u;
+       uint64_t ptr[4];
+} sg_comp_t;
+
+#endif /* _CPT_MCODE_DEFINES_H_ */
diff --git a/drivers/common/cpt/cpt_pmd_ops_helper.c b/drivers/common/cpt/cpt_pmd_ops_helper.c
new file mode 100644 (file)
index 0000000..1c18180
--- /dev/null
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Cavium, Inc
+ */
+
+#include <rte_common.h>
+
+#include "cpt_common.h"
+#include "cpt_hw_types.h"
+#include "cpt_mcode_defines.h"
+#include "cpt_pmd_ops_helper.h"
+
+#define CPT_MAX_IV_LEN 16
+#define CPT_OFFSET_CONTROL_BYTES 8
+
+int32_t
+cpt_pmd_ops_helper_get_mlen_direct_mode(void)
+{
+       uint32_t len = 0;
+
+       /* Request structure */
+       len = sizeof(struct cpt_request_info);
+
+       /* CPT HW result structure plus extra as it is aligned */
+       len += 2*sizeof(cpt_res_s_t);
+
+       return len;
+}
+
+int
+cpt_pmd_ops_helper_get_mlen_sg_mode(void)
+{
+       uint32_t len = 0;
+
+       len += sizeof(struct cpt_request_info);
+       len += CPT_OFFSET_CONTROL_BYTES + CPT_MAX_IV_LEN;
+       len += ROUNDUP8(SG_LIST_HDR_SIZE +
+                       (ROUNDUP4(CPT_MAX_SG_IN_OUT_CNT) >> 2) * SG_ENTRY_SIZE);
+       len += 2 * COMPLETION_CODE_SIZE;
+       len += 2 * sizeof(cpt_res_s_t);
+       return len;
+}
diff --git a/drivers/common/cpt/cpt_pmd_ops_helper.h b/drivers/common/cpt/cpt_pmd_ops_helper.h
new file mode 100644 (file)
index 0000000..dd32f9a
--- /dev/null
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Cavium, Inc
+ */
+
+#ifndef _CPT_PMD_OPS_HELPER_H_
+#define _CPT_PMD_OPS_HELPER_H_
+
+/*
+ * This file defines the agreement between the common layer and the individual
+ * crypto drivers for OCTEON TX series. Control path in otx* directory can
+ * directly call functions declared here.
+ */
+
+/*
+ * Get meta length required when operating in direct mode (single buffer
+ * in-place)
+ *
+ * @return
+ *   - length
+ */
+
+int32_t
+cpt_pmd_ops_helper_get_mlen_direct_mode(void);
+
+/*
+ * Get size of contiguous meta buffer to be allocated when working in scatter
+ * gather mode.
+ *
+ * @return
+ *   - length
+ */
+int
+cpt_pmd_ops_helper_get_mlen_sg_mode(void);
+#endif /* _CPT_PMD_OPS_HELPER_H_ */
diff --git a/drivers/common/cpt/meson.build b/drivers/common/cpt/meson.build
new file mode 100644 (file)
index 0000000..0a905aa
--- /dev/null
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Cavium, Inc
+
+sources = files('cpt_pmd_ops_helper.c')
+
+deps = ['kvargs', 'pci', 'cryptodev']
+includes += include_directories('../../crypto/octeontx')
+allow_experimental_apis = true
diff --git a/drivers/common/cpt/rte_common_cpt_version.map b/drivers/common/cpt/rte_common_cpt_version.map
new file mode 100644 (file)
index 0000000..dec614f
--- /dev/null
@@ -0,0 +1,6 @@
+DPDK_18.11 {
+       global:
+
+       cpt_pmd_ops_helper_get_mlen_direct_mode;
+       cpt_pmd_ops_helper_get_mlen_sg_mode;
+};
index 0257d4d..a509341 100644 (file)
@@ -2,6 +2,6 @@
 # Copyright(c) 2018 Cavium, Inc
 
 std_deps = ['eal']
-drivers = ['dpaax', 'mvep', 'octeontx', 'qat']
+drivers = ['cpt', 'dpaax', 'mvep', 'octeontx', 'qat']
 config_flag_fmt = 'RTE_LIBRTE_@0@_COMMON'
 driver_name_fmt = 'rte_common_@0@'
index 6391f72..ec30387 100644 (file)
@@ -94,6 +94,10 @@ ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
 endif
 
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO),y)
+_LDLIBS-y += -lrte_common_cpt
+endif
+
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF)$(CONFIG_RTE_LIBRTE_OCTEONTX_MEMPOOL),yy)
 _LDLIBS-y += -lrte_common_octeontx
 endif