[v2,10/33] common/cpt: add PMD ops helper functions
Checks
Commit Message
From: Murthy NSSR <nidadavolu.murthy@caviumnetworks.com>
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 | 4 +++
drivers/common/cpt/Makefile | 25 ++++++++++++++++
drivers/common/cpt/cpt_common.h | 41 +++++++++++++++++++++++++++
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, 202 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
Comments
On 9/4/2018 9:28 AM, Anoob Joseph wrote:
> From: Murthy NSSR <nidadavolu.murthy@caviumnetworks.com>
>
> 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 | 4 +++
> drivers/common/cpt/Makefile | 25 ++++++++++++++++
> drivers/common/cpt/cpt_common.h | 41 +++++++++++++++++++++++++++
> 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, 202 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 0fd2237..ca4e854 100644
> --- a/drivers/common/Makefile
> +++ b/drivers/common/Makefile
> @@ -8,4 +8,8 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF)$(CONFIG_RTE_LIBRTE_OCTEONTX_MEMPOO
> DIRS-y += octeontx
> endif
>
> +ifeq ($(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO),y)
> +DIRS-y += cpt
> +endif
> +
> include $(RTE_SDK)/mk/rte.subdir.mk
> 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 feca5fe..1f78d42 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)++)
> +
> /* cpt instance */
> struct cpt_instance {
> uint32_t queue_id;
> @@ -51,4 +69,27 @@ struct pending_queue {
> /**< Pending requests count */
> };
>
> +struct cpt_request_info {
> + /* fast path fields */
> + uint64_t dma_mode : 2;
> + /**< DMA mode */
> + uint64_t se_req : 1;
> + /**< To SE core */
> + uint64_t comp_baddr : 61;
> + volatile uint64_t *completion_addr;
> + volatile uint64_t *alternate_caddr;
> + void *op;
> + /**< Reference to operation */
better to have comments in the same line wherever possible and if not,
please check indentation.
Please check other patches as well.
HI Akhil,
On 17-09-2018 18:17, Akhil Goyal wrote:
> External Email
>
> On 9/4/2018 9:28 AM, Anoob Joseph wrote:
>> From: Murthy NSSR <nidadavolu.murthy@caviumnetworks.com>
>>
>> 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 | 4 +++
>> drivers/common/cpt/Makefile | 25 ++++++++++++++++
>> drivers/common/cpt/cpt_common.h | 41
>> +++++++++++++++++++++++++++
>> 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, 202 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 0fd2237..ca4e854 100644
>> --- a/drivers/common/Makefile
>> +++ b/drivers/common/Makefile
>> @@ -8,4 +8,8 @@ ifeq
>> ($(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF)$(CONFIG_RTE_LIBRTE_OCTEONTX_MEMPOO
>> DIRS-y += octeontx
>> endif
>>
>> +ifeq ($(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO),y)
>> +DIRS-y += cpt
>> +endif
>> +
>> include $(RTE_SDK)/mk/rte.subdir.mk
>> 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 feca5fe..1f78d42 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)++)
>> +
>> /* cpt instance */
>> struct cpt_instance {
>> uint32_t queue_id;
>> @@ -51,4 +69,27 @@ struct pending_queue {
>> /**< Pending requests count */
>> };
>>
>> +struct cpt_request_info {
>> + /* fast path fields */
>> + uint64_t dma_mode : 2;
>> + /**< DMA mode */
>> + uint64_t se_req : 1;
>> + /**< To SE core */
>> + uint64_t comp_baddr : 61;
>> + volatile uint64_t *completion_addr;
>> + volatile uint64_t *alternate_caddr;
>> + void *op;
>> + /**< Reference to operation */
> better to have comments in the same line wherever possible and if not,
> please check indentation.
> Please check other patches as well.
>
Will fix this in v3. I'll try to make all comments on the line before
the thing.
Anoob
@@ -8,4 +8,8 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF)$(CONFIG_RTE_LIBRTE_OCTEONTX_MEMPOO
DIRS-y += octeontx
endif
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO),y)
+DIRS-y += cpt
+endif
+
include $(RTE_SDK)/mk/rte.subdir.mk
new file mode 100644
@@ -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
@@ -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)++)
+
/* cpt instance */
struct cpt_instance {
uint32_t queue_id;
@@ -51,4 +69,27 @@ struct pending_queue {
/**< Pending requests count */
};
+struct cpt_request_info {
+ /* fast path fields */
+ uint64_t dma_mode : 2;
+ /**< DMA mode */
+ uint64_t se_req : 1;
+ /**< To SE core */
+ uint64_t comp_baddr : 61;
+ volatile uint64_t *completion_addr;
+ volatile uint64_t *alternate_caddr;
+ void *op;
+ /**< Reference to operation */
+ struct {
+ uint64_t ei0;
+ uint64_t ei1;
+ uint64_t ei2;
+ uint64_t ei3;
+ } ist;
+
+ /* slow path fields */
+ uint64_t time_out;
+ uint8_t extra_time;
+};
+
#endif /* _CPT_COMMON_H_ */
new file mode 100644
@@ -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 16
+#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_ */
new file mode 100644
@@ -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;
+}
new file mode 100644
@@ -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 OcteonTX 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_ */
new file mode 100644
@@ -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
new file mode 100644
@@ -0,0 +1,6 @@
+DPDK_18.11 {
+ global:
+
+ cpt_pmd_ops_helper_get_mlen_direct_mode;
+ cpt_pmd_ops_helper_get_mlen_sg_mode;
+};
@@ -2,6 +2,6 @@
# Copyright(c) 2018 Cavium, Inc
std_deps = ['eal']
-drivers = ['octeontx', 'qat']
+drivers = ['cpt', 'octeontx', 'qat']
config_flag_fmt = 'RTE_LIBRTE_@0@_COMMON'
driver_name_fmt = 'rte_common_@0@'
@@ -98,6 +98,10 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF)$(CONFIG_RTE_LIBRTE_OCTEONTX_MEMPOO
_LDLIBS-y += -lrte_common_octeontx
endif
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO),y)
+_LDLIBS-y += -lrte_common_cpt
+endif
+
_LDLIBS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += -lrte_bus_pci
_LDLIBS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += -lrte_bus_vdev
_LDLIBS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += -lrte_bus_dpaa