From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anoob Joseph Subject: [PATCH v4 05/23] common/cpt: add PMD ops helper functions Date: Tue, 9 Oct 2018 14:37:38 +0530 Message-ID: <1539076076-19786-6-git-send-email-anoob.joseph@caviumnetworks.com> References: <1538744363-30340-1-git-send-email-anoob.joseph@caviumnetworks.com> <1539076076-19786-1-git-send-email-anoob.joseph@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain Cc: Anoob Joseph , Jerin Jacob , Narayana Prasad , Ankur Dwivedi , Murthy NSSR , Nithin Dabilpuram , Ragothaman Jayaraman , Srisivasubramanian S , Tejasree Kondoj , dev@dpdk.org To: Akhil Goyal , Pablo de Lara , Thomas Monjalon Return-path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0069.outbound.protection.outlook.com [104.47.41.69]) by dpdk.org (Postfix) with ESMTP id C8AB91B150 for ; Tue, 9 Oct 2018 11:09:00 +0200 (CEST) In-Reply-To: <1539076076-19786-1-git-send-email-anoob.joseph@caviumnetworks.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Signed-off-by: Anoob Joseph Signed-off-by: Murthy NSSR Signed-off-by: Nithin Dabilpuram Signed-off-by: Ragothaman Jayaraman Signed-off-by: Srisivasubramanian S Signed-off-by: Tejasree Kondoj --- drivers/common/Makefile | 4 +++ drivers/common/cpt/Makefile | 25 ++++++++++++++++ drivers/common/cpt/cpt_common.h | 36 +++++++++++++++++++++++ drivers/common/cpt/cpt_mcode_defines.h | 38 +++++++++++++++++++++++++ drivers/common/cpt/cpt_pmd_ops_helper.c | 41 +++++++++++++++++++++++++++ drivers/common/cpt/cpt_pmd_ops_helper.h | 34 ++++++++++++++++++++++ drivers/common/cpt/meson.build | 8 ++++++ drivers/common/cpt/rte_common_cpt_version.map | 6 ++++ drivers/common/meson.build | 2 +- mk/rte.app.mk | 4 +++ 10 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 drivers/common/cpt/Makefile create mode 100644 drivers/common/cpt/cpt_mcode_defines.h create mode 100644 drivers/common/cpt/cpt_pmd_ops_helper.c create mode 100644 drivers/common/cpt/cpt_pmd_ops_helper.h create mode 100644 drivers/common/cpt/meson.build create mode 100644 drivers/common/cpt/rte_common_cpt_version.map diff --git a/drivers/common/Makefile b/drivers/common/Makefile index 5bcff17..29a8f6d 100644 --- a/drivers/common/Makefile +++ b/drivers/common/Makefile @@ -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 index 0000000..2340aa9 --- /dev/null +++ b/drivers/common/cpt/Makefile @@ -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 diff --git a/drivers/common/cpt/cpt_common.h b/drivers/common/cpt/cpt_common.h index 5e2099a..88f4902 100644 --- a/drivers/common/cpt/cpt_common.h +++ b/drivers/common/cpt/cpt_common.h @@ -18,6 +18,24 @@ #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 index 0000000..83a8a42 --- /dev/null +++ b/drivers/common/cpt/cpt_mcode_defines.h @@ -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 index 0000000..1c18180 --- /dev/null +++ b/drivers/common/cpt/cpt_pmd_ops_helper.c @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Cavium, Inc + */ + +#include + +#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 index 0000000..dd32f9a --- /dev/null +++ b/drivers/common/cpt/cpt_pmd_ops_helper.h @@ -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 index 0000000..0a905aa --- /dev/null +++ b/drivers/common/cpt/meson.build @@ -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 index 0000000..dec614f --- /dev/null +++ b/drivers/common/cpt/rte_common_cpt_version.map @@ -0,0 +1,6 @@ +DPDK_18.11 { + global: + + cpt_pmd_ops_helper_get_mlen_direct_mode; + cpt_pmd_ops_helper_get_mlen_sg_mode; +}; diff --git a/drivers/common/meson.build b/drivers/common/meson.build index f828ce7..dd14f85 100644 --- a/drivers/common/meson.build +++ b/drivers/common/meson.build @@ -2,6 +2,6 @@ # Copyright(c) 2018 Cavium, Inc std_deps = ['eal'] -drivers = ['mvep', 'octeontx', 'qat'] +drivers = ['cpt', 'mvep', 'octeontx', 'qat'] config_flag_fmt = 'RTE_LIBRTE_@0@_COMMON' driver_name_fmt = 'rte_common_@0@' diff --git a/mk/rte.app.mk b/mk/rte.app.mk index 9661cdf..946d3e9 100644 --- a/mk/rte.app.mk +++ b/mk/rte.app.mk @@ -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 -- 2.7.4