* [dpdk-dev] [PATCH 0/3] crypto/mvsam: yet another round of features @ 2018-08-27 12:22 Tomasz Duszynski 2018-08-27 12:22 ` [dpdk-dev] [PATCH 1/3] crypto/mvsam: add S/G support to crypto dirver Tomasz Duszynski ` (3 more replies) 0 siblings, 4 replies; 11+ messages in thread From: Tomasz Duszynski @ 2018-08-27 12:22 UTC (permalink / raw) To: dev; +Cc: nsamsono, mw, Tomasz Duszynski Following changes are introduced in this patch series: * Add S/G support. * Start using common/mvep for DMA memory initialization. * Add dynamic logging support. Note that 'crypto/mvsam: common use initialization' relies on 'net/mvpp2: use common code to initialize DMA' which is now on dpdk-next-net/master. Dmitri Epshtein (1): crypto/mvsam: use common initialization Tomasz Duszynski (1): crypto/mvsam: add dynamic logging support Zyta Szpak (1): crypto/mvsam: add S/G support to crypto dirver config/common_base | 1 - drivers/common/Makefile | 4 +- drivers/crypto/mvsam/Makefile | 3 +- drivers/crypto/mvsam/meson.build | 2 +- drivers/crypto/mvsam/rte_mrvl_pmd.c | 192 +++++++++++++++++----------- drivers/crypto/mvsam/rte_mrvl_pmd_ops.c | 10 +- drivers/crypto/mvsam/rte_mrvl_pmd_private.h | 34 ++--- mk/rte.app.mk | 4 +- 8 files changed, 143 insertions(+), 107 deletions(-) -- 2.7.4 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [dpdk-dev] [PATCH 1/3] crypto/mvsam: add S/G support to crypto dirver 2018-08-27 12:22 [dpdk-dev] [PATCH 0/3] crypto/mvsam: yet another round of features Tomasz Duszynski @ 2018-08-27 12:22 ` Tomasz Duszynski 2018-09-17 14:07 ` Akhil Goyal 2018-08-27 12:22 ` [dpdk-dev] [PATCH 2/3] crypto/mvsam: use common initialization Tomasz Duszynski ` (2 subsequent siblings) 3 siblings, 1 reply; 11+ messages in thread From: Tomasz Duszynski @ 2018-08-27 12:22 UTC (permalink / raw) To: dev; +Cc: nsamsono, mw, Zyta Szpak From: Zyta Szpak <zr@semihalf.com> The patch adds support for chained source mbufs given to crypto operations. The crypto engine accepts source buffer containing a number of segments. The destination buffer stays the same - always one segment. On decryption, EIP engine will look for digest at 'auth_icv_offset' offset in SRC buffer.It must be placed in the last segment and the offset must be set to reach digest in the last segment. If application doesn't placed digest in source mbuf, driver try to copy it to a last segment. Signed-off-by: Zyta Szpak <zr@semihalf.com> Signed-off-by: Natalie Samsonov <nsamsono@marvell.com> Reviewed-by: Dmitri Epshtein <dima@marvell.com> --- drivers/crypto/mvsam/rte_mrvl_pmd.c | 96 +++++++++++++++++++++-------- drivers/crypto/mvsam/rte_mrvl_pmd_private.h | 7 +++ 2 files changed, 76 insertions(+), 27 deletions(-) diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c index 961802e..001aa28 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd.c +++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c @@ -452,8 +452,10 @@ mrvl_request_prepare(struct sam_cio_op_params *request, struct rte_crypto_op *op) { struct mrvl_crypto_session *sess; - struct rte_mbuf *dst_mbuf; + struct rte_mbuf *src_mbuf, *dst_mbuf; + uint16_t segments_nb; uint8_t *digest; + int i; if (unlikely(op->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) { MRVL_CRYPTO_LOG_ERR("MRVL CRYPTO PMD only supports session " @@ -469,29 +471,47 @@ mrvl_request_prepare(struct sam_cio_op_params *request, return -EINVAL; } - /* + request->sa = sess->sam_sess; + request->cookie = op; + + src_mbuf = op->sym->m_src; + segments_nb = src_mbuf->nb_segs; + /* The following conditions must be met: + * - Destination buffer is required when segmented source buffer + * - Segmented destination buffer is not supported + */ + if ((segments_nb > 1) && (!op->sym->m_dst)) { + MRVL_CRYPTO_LOG_ERR("op->sym->m_dst = NULL!\n"); + return -1; + } + /* For non SG case: * If application delivered us null dst buffer, it means it expects * us to deliver the result in src buffer. */ dst_mbuf = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src; - request->sa = sess->sam_sess; - request->cookie = op; - - /* Single buffers only, sorry. */ - request->num_bufs = 1; - request->src = src_bd; - src_bd->vaddr = rte_pktmbuf_mtod(op->sym->m_src, void *); - src_bd->paddr = rte_pktmbuf_iova(op->sym->m_src); - src_bd->len = rte_pktmbuf_data_len(op->sym->m_src); - - /* Empty source. */ - if (rte_pktmbuf_data_len(op->sym->m_src) == 0) { - /* EIP does not support 0 length buffers. */ - MRVL_CRYPTO_LOG_ERR("Buffer length == 0 not supported!"); + if (!rte_pktmbuf_is_contiguous(dst_mbuf)) { + MRVL_CRYPTO_LOG_ERR("Segmented destination buffer " + "not supported.\n"); return -1; } + request->num_bufs = segments_nb; + for (i = 0; i < segments_nb; i++) { + /* Empty source. */ + if (rte_pktmbuf_data_len(src_mbuf) == 0) { + /* EIP does not support 0 length buffers. */ + MRVL_CRYPTO_LOG_ERR("Buffer length == 0 not supported!"); + return -1; + } + src_bd[i].vaddr = rte_pktmbuf_mtod(src_mbuf, void *); + src_bd[i].paddr = rte_pktmbuf_iova(src_mbuf); + src_bd[i].len = rte_pktmbuf_data_len(src_mbuf); + + src_mbuf = src_mbuf->next; + } + request->src = src_bd; + /* Empty destination. */ if (rte_pktmbuf_data_len(dst_mbuf) == 0) { /* Make dst buffer fit at least source data. */ @@ -542,7 +562,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, /* * EIP supports only scenarios where ICV(digest buffer) is placed at - * auth_icv_offset. Any other placement means risking errors. + * auth_icv_offset. */ if (sess->sam_sess_params.dir == SAM_DIR_ENCRYPT) { /* @@ -551,17 +571,36 @@ mrvl_request_prepare(struct sam_cio_op_params *request, */ if (rte_pktmbuf_mtod_offset( dst_mbuf, uint8_t *, - request->auth_icv_offset) == digest) { + request->auth_icv_offset) == digest) return 0; - } } else {/* sess->sam_sess_params.dir == SAM_DIR_DECRYPT */ /* * EIP will look for digest at auth_icv_offset - * offset in SRC buffer. + * offset in SRC buffer. It must be placed in the last + * segment and the offset must be set to reach digest + * in the last segment */ - if (rte_pktmbuf_mtod_offset( - op->sym->m_src, uint8_t *, - request->auth_icv_offset) == digest) { + struct rte_mbuf *last_seg = op->sym->m_src; + uint32_t d_offset = request->auth_icv_offset; + u32 d_size = sess->sam_sess_params.u.basic.auth_icv_len; + unsigned char *d_ptr; + + /* Find the last segment and the offset for the last segment */ + while ((last_seg->next != NULL) && + (d_offset >= last_seg->data_len)) { + d_offset -= last_seg->data_len; + last_seg = last_seg->next; + } + + if (rte_pktmbuf_mtod_offset(last_seg, uint8_t *, + d_offset) == digest) + return 0; + + /* copy digest to last segment */ + if (last_seg->buf_len >= (d_size + d_offset)) { + d_ptr = (unsigned char *)last_seg->buf_addr + + d_offset; + rte_memcpy(d_ptr, digest, d_size); return 0; } } @@ -597,11 +636,10 @@ mrvl_crypto_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, int ret; struct sam_cio_op_params requests[nb_ops]; /* - * DPDK uses single fragment buffers, so we can KISS descriptors. * SAM does not store bd pointers, so on-stack scope will be enough. */ - struct sam_buf_info src_bd[nb_ops]; - struct sam_buf_info dst_bd[nb_ops]; + struct mrvl_crypto_src_table src_bd[nb_ops]; + struct sam_buf_info dst_bd[nb_ops]; struct mrvl_crypto_qp *qp = (struct mrvl_crypto_qp *)queue_pair; if (nb_ops == 0) @@ -609,11 +647,14 @@ mrvl_crypto_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, /* Prepare the burst. */ memset(&requests, 0, sizeof(requests)); + memset(&src_bd, 0, sizeof(src_bd)); /* Iterate through */ for (; iter_ops < nb_ops; ++iter_ops) { + /* store the op id for debug */ + src_bd[iter_ops].iter_ops = iter_ops; if (mrvl_request_prepare(&requests[iter_ops], - &src_bd[iter_ops], + src_bd[iter_ops].src_bd, &dst_bd[iter_ops], ops[iter_ops]) < 0) { MRVL_CRYPTO_LOG_ERR( @@ -767,6 +808,7 @@ cryptodev_mrvl_crypto_create(const char *name, sam_params.max_num_sessions = internals->max_nb_sessions; + /* sam_set_debug_flags(3); */ return sam_init(&sam_params); init_error: diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_private.h b/drivers/crypto/mvsam/rte_mrvl_pmd_private.h index c16d95b..0689fc3 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd_private.h +++ b/drivers/crypto/mvsam/rte_mrvl_pmd_private.h @@ -38,6 +38,8 @@ */ #define BITS2BYTES(x) ((x) >> 3) +#define MRVL_MAX_SEGMENTS 16 + /** The operation order mode enumerator. */ enum mrvl_crypto_chain_order { MRVL_CRYPTO_CHAIN_CIPHER_ONLY, @@ -84,6 +86,11 @@ struct mrvl_crypto_session { uint16_t cipher_iv_offset; } __rte_cache_aligned; +struct mrvl_crypto_src_table { + uint16_t iter_ops; + struct sam_buf_info src_bd[MRVL_MAX_SEGMENTS]; +} __rte_cache_aligned; + /** Set and validate MRVL crypto session parameters */ extern int mrvl_crypto_set_session_parameters(struct mrvl_crypto_session *sess, -- 2.7.4 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [dpdk-dev] [PATCH 1/3] crypto/mvsam: add S/G support to crypto dirver 2018-08-27 12:22 ` [dpdk-dev] [PATCH 1/3] crypto/mvsam: add S/G support to crypto dirver Tomasz Duszynski @ 2018-09-17 14:07 ` Akhil Goyal 2018-09-21 13:18 ` Andrzej Ostruszka 0 siblings, 1 reply; 11+ messages in thread From: Akhil Goyal @ 2018-09-17 14:07 UTC (permalink / raw) To: Tomasz Duszynski, dev; +Cc: nsamsono, mw, Zyta Szpak Hi Tomasz, On 8/27/2018 5:52 PM, Tomasz Duszynski wrote: > From: Zyta Szpak <zr@semihalf.com> > > The patch adds support for chained source mbufs given > to crypto operations. The crypto engine accepts source buffer > containing a number of segments. The destination buffer > stays the same - always one segment. > On decryption, EIP engine will look for digest at 'auth_icv_offset' > offset in SRC buffer.It must be placed in the last segment and the > offset must be set to reach digest in the last segment. > If application doesn't placed digest in source mbuf, driver try to > copy it to a last segment. > > Signed-off-by: Zyta Szpak <zr@semihalf.com> > Signed-off-by: Natalie Samsonov <nsamsono@marvell.com> > Reviewed-by: Dmitri Epshtein <dima@marvell.com> > --- > drivers/crypto/mvsam/rte_mrvl_pmd.c | 96 +++++++++++++++++++++-------- > drivers/crypto/mvsam/rte_mrvl_pmd_private.h | 7 +++ > 2 files changed, 76 insertions(+), 27 deletions(-) > > diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c > index 961802e..001aa28 100644 > --- a/drivers/crypto/mvsam/rte_mrvl_pmd.c > +++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c > @@ -452,8 +452,10 @@ mrvl_request_prepare(struct sam_cio_op_params *request, > struct rte_crypto_op *op) > { > struct mrvl_crypto_session *sess; > - struct rte_mbuf *dst_mbuf; > + struct rte_mbuf *src_mbuf, *dst_mbuf; > + uint16_t segments_nb; > uint8_t *digest; > + int i; > > if (unlikely(op->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) { > MRVL_CRYPTO_LOG_ERR("MRVL CRYPTO PMD only supports session " > @@ -469,29 +471,47 @@ mrvl_request_prepare(struct sam_cio_op_params *request, > return -EINVAL; > } > > - /* > + request->sa = sess->sam_sess; > + request->cookie = op; > + > + src_mbuf = op->sym->m_src; > + segments_nb = src_mbuf->nb_segs; > + /* The following conditions must be met: > + * - Destination buffer is required when segmented source buffer > + * - Segmented destination buffer is not supported > + */ > + if ((segments_nb > 1) && (!op->sym->m_dst)) { > + MRVL_CRYPTO_LOG_ERR("op->sym->m_dst = NULL!\n"); > + return -1; > + } > + /* For non SG case: > * If application delivered us null dst buffer, it means it expects > * us to deliver the result in src buffer. > */ > dst_mbuf = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src; > > - request->sa = sess->sam_sess; > - request->cookie = op; > - > - /* Single buffers only, sorry. */ > - request->num_bufs = 1; > - request->src = src_bd; > - src_bd->vaddr = rte_pktmbuf_mtod(op->sym->m_src, void *); > - src_bd->paddr = rte_pktmbuf_iova(op->sym->m_src); > - src_bd->len = rte_pktmbuf_data_len(op->sym->m_src); > - > - /* Empty source. */ > - if (rte_pktmbuf_data_len(op->sym->m_src) == 0) { > - /* EIP does not support 0 length buffers. */ > - MRVL_CRYPTO_LOG_ERR("Buffer length == 0 not supported!"); > + if (!rte_pktmbuf_is_contiguous(dst_mbuf)) { > + MRVL_CRYPTO_LOG_ERR("Segmented destination buffer " > + "not supported.\n"); > return -1; > } > > + request->num_bufs = segments_nb; > + for (i = 0; i < segments_nb; i++) { > + /* Empty source. */ > + if (rte_pktmbuf_data_len(src_mbuf) == 0) { > + /* EIP does not support 0 length buffers. */ > + MRVL_CRYPTO_LOG_ERR("Buffer length == 0 not supported!"); > + return -1; > + } > + src_bd[i].vaddr = rte_pktmbuf_mtod(src_mbuf, void *); > + src_bd[i].paddr = rte_pktmbuf_iova(src_mbuf); > + src_bd[i].len = rte_pktmbuf_data_len(src_mbuf); > + > + src_mbuf = src_mbuf->next; > + } > + request->src = src_bd; > + > /* Empty destination. */ > if (rte_pktmbuf_data_len(dst_mbuf) == 0) { > /* Make dst buffer fit at least source data. */ > @@ -542,7 +562,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, > > /* > * EIP supports only scenarios where ICV(digest buffer) is placed at > - * auth_icv_offset. Any other placement means risking errors. > + * auth_icv_offset. > */ > if (sess->sam_sess_params.dir == SAM_DIR_ENCRYPT) { > /* > @@ -551,17 +571,36 @@ mrvl_request_prepare(struct sam_cio_op_params *request, > */ > if (rte_pktmbuf_mtod_offset( > dst_mbuf, uint8_t *, > - request->auth_icv_offset) == digest) { > + request->auth_icv_offset) == digest) > return 0; > - } > } else {/* sess->sam_sess_params.dir == SAM_DIR_DECRYPT */ > /* > * EIP will look for digest at auth_icv_offset > - * offset in SRC buffer. > + * offset in SRC buffer. It must be placed in the last > + * segment and the offset must be set to reach digest > + * in the last segment > */ > - if (rte_pktmbuf_mtod_offset( > - op->sym->m_src, uint8_t *, > - request->auth_icv_offset) == digest) { > + struct rte_mbuf *last_seg = op->sym->m_src; > + uint32_t d_offset = request->auth_icv_offset; > + u32 d_size = sess->sam_sess_params.u.basic.auth_icv_len; > + unsigned char *d_ptr; > + > + /* Find the last segment and the offset for the last segment */ > + while ((last_seg->next != NULL) && > + (d_offset >= last_seg->data_len)) { > + d_offset -= last_seg->data_len; > + last_seg = last_seg->next; > + } > + > + if (rte_pktmbuf_mtod_offset(last_seg, uint8_t *, > + d_offset) == digest) > + return 0; > + > + /* copy digest to last segment */ > + if (last_seg->buf_len >= (d_size + d_offset)) { > + d_ptr = (unsigned char *)last_seg->buf_addr + > + d_offset; > + rte_memcpy(d_ptr, digest, d_size); > return 0; > } > } > @@ -597,11 +636,10 @@ mrvl_crypto_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, > int ret; > struct sam_cio_op_params requests[nb_ops]; > /* > - * DPDK uses single fragment buffers, so we can KISS descriptors. > * SAM does not store bd pointers, so on-stack scope will be enough. > */ > - struct sam_buf_info src_bd[nb_ops]; > - struct sam_buf_info dst_bd[nb_ops]; > + struct mrvl_crypto_src_table src_bd[nb_ops]; > + struct sam_buf_info dst_bd[nb_ops]; > struct mrvl_crypto_qp *qp = (struct mrvl_crypto_qp *)queue_pair; > > if (nb_ops == 0) > @@ -609,11 +647,14 @@ mrvl_crypto_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, > > /* Prepare the burst. */ > memset(&requests, 0, sizeof(requests)); > + memset(&src_bd, 0, sizeof(src_bd)); > > /* Iterate through */ > for (; iter_ops < nb_ops; ++iter_ops) { > + /* store the op id for debug */ > + src_bd[iter_ops].iter_ops = iter_ops; > if (mrvl_request_prepare(&requests[iter_ops], > - &src_bd[iter_ops], > + src_bd[iter_ops].src_bd, > &dst_bd[iter_ops], > ops[iter_ops]) < 0) { > MRVL_CRYPTO_LOG_ERR( > @@ -767,6 +808,7 @@ cryptodev_mrvl_crypto_create(const char *name, > > sam_params.max_num_sessions = internals->max_nb_sessions; > > + /* sam_set_debug_flags(3); */ > return sam_init(&sam_params); > > init_error: > diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_private.h b/drivers/crypto/mvsam/rte_mrvl_pmd_private.h > index c16d95b..0689fc3 100644 > --- a/drivers/crypto/mvsam/rte_mrvl_pmd_private.h > +++ b/drivers/crypto/mvsam/rte_mrvl_pmd_private.h > @@ -38,6 +38,8 @@ > */ > #define BITS2BYTES(x) ((x) >> 3) > > +#define MRVL_MAX_SEGMENTS 16 > + > /** The operation order mode enumerator. */ > enum mrvl_crypto_chain_order { > MRVL_CRYPTO_CHAIN_CIPHER_ONLY, > @@ -84,6 +86,11 @@ struct mrvl_crypto_session { > uint16_t cipher_iv_offset; > } __rte_cache_aligned; > > +struct mrvl_crypto_src_table { > + uint16_t iter_ops; > + struct sam_buf_info src_bd[MRVL_MAX_SEGMENTS]; > +} __rte_cache_aligned; > + > /** Set and validate MRVL crypto session parameters */ > extern int > mrvl_crypto_set_session_parameters(struct mrvl_crypto_session *sess, > Please update the doc file for pmd and also set appropriate feature flag for scatter gather support. #define RTE_CRYPTODEV_FF_IN_PLACE_SGL (1ULL << 9) /**< In-place Scatter-gather (SGL) buffers, with multiple segments, * are supported */ #define RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT (1ULL << 10) /**< Out-of-place Scatter-gather (SGL) buffers are * supported in input and output */ #define RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT (1ULL << 11) /**< Out-of-place Scatter-gather (SGL) buffers are supported * in input, combined with linear buffers (LB), with a * single segment in output */ #define RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT (1ULL << 12) /**< Out-of-place Scatter-gather (SGL) buffers are supported * in output, combined with linear buffers (LB) in input */ #define RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT (1ULL << 13) /**< Out-of-place linear buffers (LB) are supported in input and output */ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [dpdk-dev] [PATCH 1/3] crypto/mvsam: add S/G support to crypto dirver 2018-09-17 14:07 ` Akhil Goyal @ 2018-09-21 13:18 ` Andrzej Ostruszka 0 siblings, 0 replies; 11+ messages in thread From: Andrzej Ostruszka @ 2018-09-21 13:18 UTC (permalink / raw) To: Akhil Goyal, dev; +Cc: Tomasz Duszynski, nsamsono, mw, Zyta Szpak Hello Akhil I'm taking over handling of the patches submitted by Tomasz. First of all, thank you for taking time to review them. On 17.09.2018 16:07, Akhil Goyal wrote: > Hi Tomasz, [...] > Please update the doc file for pmd and also set appropriate feature flag for scatter gather support. [...] This is actually already done in pending patch: http://patches.dpdk.org/patch/44254/ I will send shortly updated version of this patch series though - there were some issues with application of them and I aligned some Makefiles with pending NETA driver patches to make them apply without issues. Best regards Andrzej ^ permalink raw reply [flat|nested] 11+ messages in thread
* [dpdk-dev] [PATCH 2/3] crypto/mvsam: use common initialization 2018-08-27 12:22 [dpdk-dev] [PATCH 0/3] crypto/mvsam: yet another round of features Tomasz Duszynski 2018-08-27 12:22 ` [dpdk-dev] [PATCH 1/3] crypto/mvsam: add S/G support to crypto dirver Tomasz Duszynski @ 2018-08-27 12:22 ` Tomasz Duszynski 2018-08-27 12:22 ` [dpdk-dev] [PATCH 3/3] crypto/mvsam: add dynamic logging support Tomasz Duszynski 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 0/3] crypto/mvsam: yet another round of features Andrzej Ostruszka 3 siblings, 0 replies; 11+ messages in thread From: Tomasz Duszynski @ 2018-08-27 12:22 UTC (permalink / raw) To: dev; +Cc: nsamsono, mw, Dmitri Epshtein, Tomasz Duszynski From: Dmitri Epshtein <dima@marvell.com> Use common initialization to reduce boilerplate code. Signed-off-by: Dmitri Epshtein <dima@marvell.com> Signed-off-by: Tomasz Duszynski <tdu@semihalf.com> Reviewed-by: Natalie Samsonov <nsamsono@marvell.com> --- drivers/common/Makefile | 4 +++- drivers/crypto/mvsam/Makefile | 3 ++- drivers/crypto/mvsam/meson.build | 2 +- drivers/crypto/mvsam/rte_mrvl_pmd.c | 30 +++++++++++++----------------- mk/rte.app.mk | 4 +++- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/drivers/common/Makefile b/drivers/common/Makefile index 5f72da0..5bcff17 100644 --- a/drivers/common/Makefile +++ b/drivers/common/Makefile @@ -8,7 +8,9 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF)$(CONFIG_RTE_LIBRTE_OCTEONTX_MEMPOO DIRS-y += octeontx endif -ifeq ($(CONFIG_RTE_LIBRTE_MVPP2_PMD),y) +MVEP-y += $(CONFIG_RTE_LIBRTE_MVPP2_PMD) +MVEP-y += $(CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO) +ifneq (,$(filter y,$(MVEP-y))) DIRS-y += mvep endif diff --git a/drivers/crypto/mvsam/Makefile b/drivers/crypto/mvsam/Makefile index 3290147..2b4d036 100644 --- a/drivers/crypto/mvsam/Makefile +++ b/drivers/crypto/mvsam/Makefile @@ -19,6 +19,7 @@ LIB = librte_pmd_mvsam_crypto.a # build flags CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -I$(RTE_SDK)/drivers/common/mvep CFLAGS += -I$(LIBMUSDK_PATH)/include CFLAGS += -DMVCONF_TYPES_PUBLIC CFLAGS += -DMVCONF_DMA_PHYS_ADDR_T_PUBLIC @@ -33,7 +34,7 @@ EXPORT_MAP := rte_pmd_mvsam_version.map LDLIBS += -L$(LIBMUSDK_PATH)/lib -lmusdk LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_kvargs LDLIBS += -lrte_cryptodev -LDLIBS += -lrte_bus_vdev +LDLIBS += -lrte_bus_vdev -lrte_common_mvep # library source files SRCS-$(CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO) += rte_mrvl_pmd.c diff --git a/drivers/crypto/mvsam/meson.build b/drivers/crypto/mvsam/meson.build index 3c8ea3c..f1c8796 100644 --- a/drivers/crypto/mvsam/meson.build +++ b/drivers/crypto/mvsam/meson.build @@ -18,4 +18,4 @@ endif sources = files('rte_mrvl_pmd.c', 'rte_mrvl_pmd_ops.c') -deps += ['bus_vdev'] +deps += ['bus_vdev', 'common_mvep'] diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c index 001aa28..9c3bb91 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd.c +++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c @@ -12,11 +12,10 @@ #include <rte_malloc.h> #include <rte_cpuflags.h> #include <rte_kvargs.h> +#include <rte_mvep_common.h> #include "rte_mrvl_pmd_private.h" -#define MRVL_MUSDK_DMA_MEMSIZE 41943040 - #define MRVL_PMD_MAX_NB_SESS_ARG ("max_nb_sessions") #define MRVL_PMD_DEFAULT_MAX_NB_SESSIONS 2048 @@ -767,7 +766,7 @@ cryptodev_mrvl_crypto_create(const char *name, struct rte_cryptodev *dev; struct mrvl_crypto_private *internals; struct sam_init_params sam_params; - int ret; + int ret = -EINVAL; dev = rte_cryptodev_pmd_create(name, &vdev->device, &init_params->common); @@ -793,30 +792,26 @@ cryptodev_mrvl_crypto_create(const char *name, internals->max_nb_qpairs = init_params->common.max_nb_queue_pairs; internals->max_nb_sessions = init_params->max_nb_sessions; - /* - * ret == -EEXIST is correct, it means DMA - * has been already initialized. - */ - ret = mv_sys_dma_mem_init(MRVL_MUSDK_DMA_MEMSIZE); - if (ret < 0) { - if (ret != -EEXIST) - return ret; - - MRVL_CRYPTO_LOG_INFO( - "DMA memory has been already initialized by a different driver."); - } + ret = rte_mvep_init(MVEP_MOD_T_SAM, NULL); + if (ret) + goto init_error; sam_params.max_num_sessions = internals->max_nb_sessions; /* sam_set_debug_flags(3); */ - return sam_init(&sam_params); + + ret = sam_init(&sam_params); + if (ret) + goto init_error; + + return 0; init_error: MRVL_CRYPTO_LOG_ERR( "driver %s: %s failed", init_params->common.name, __func__); cryptodev_mrvl_crypto_uninit(vdev); - return -EFAULT; + return ret; } /** Parse integer from integer argument */ @@ -966,6 +961,7 @@ cryptodev_mrvl_crypto_uninit(struct rte_vdev_device *vdev) name, rte_socket_id()); sam_deinit(); + rte_mvep_deinit(MVEP_MOD_T_SAM); cryptodev = rte_cryptodev_pmd_get_named_dev(name); if (cryptodev == NULL) diff --git a/mk/rte.app.mk b/mk/rte.app.mk index 899d51a..c8a261e 100644 --- a/mk/rte.app.mk +++ b/mk/rte.app.mk @@ -98,7 +98,9 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF)$(CONFIG_RTE_LIBRTE_OCTEONTX_MEMPOO _LDLIBS-y += -lrte_common_octeontx endif -ifeq ($(CONFIG_RTE_LIBRTE_MVPP2_PMD),y) +MVEP-y += $(CONFIG_RTE_LIBRTE_MVPP2_PMD) +MVEP-y += $(CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO) +ifneq (,$(filter y,$(MVEP-y))) _LDLIBS-y += -lrte_common_mvep -L$(LIBMUSDK_PATH)/lib -lmusdk endif -- 2.7.4 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [dpdk-dev] [PATCH 3/3] crypto/mvsam: add dynamic logging support 2018-08-27 12:22 [dpdk-dev] [PATCH 0/3] crypto/mvsam: yet another round of features Tomasz Duszynski 2018-08-27 12:22 ` [dpdk-dev] [PATCH 1/3] crypto/mvsam: add S/G support to crypto dirver Tomasz Duszynski 2018-08-27 12:22 ` [dpdk-dev] [PATCH 2/3] crypto/mvsam: use common initialization Tomasz Duszynski @ 2018-08-27 12:22 ` Tomasz Duszynski 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 0/3] crypto/mvsam: yet another round of features Andrzej Ostruszka 3 siblings, 0 replies; 11+ messages in thread From: Tomasz Duszynski @ 2018-08-27 12:22 UTC (permalink / raw) To: dev; +Cc: nsamsono, mw, Tomasz Duszynski Add dynamic logging support to mvsam crypto PMD. Signed-off-by: Tomasz Duszynski <tdu@semihalf.com> --- config/common_base | 1 - drivers/crypto/mvsam/rte_mrvl_pmd.c | 74 ++++++++++++++--------------- drivers/crypto/mvsam/rte_mrvl_pmd_ops.c | 10 ++-- drivers/crypto/mvsam/rte_mrvl_pmd_private.h | 27 +++-------- 4 files changed, 49 insertions(+), 63 deletions(-) diff --git a/config/common_base b/config/common_base index 4bcbaf9..271f549 100644 --- a/config/common_base +++ b/config/common_base @@ -559,7 +559,6 @@ CONFIG_RTE_LIBRTE_PMD_CCP=n # Compile PMD for Marvell Crypto device # CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO=n -CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO_DEBUG=n # # Compile generic security library diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c index 9c3bb91..33dd018 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd.c +++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c @@ -224,7 +224,7 @@ mrvl_crypto_set_cipher_session_parameters(struct mrvl_crypto_session *sess, { /* Make sure we've got proper struct */ if (cipher_xform->type != RTE_CRYPTO_SYM_XFORM_CIPHER) { - MRVL_CRYPTO_LOG_ERR("Wrong xform struct provided!"); + MRVL_LOG(ERR, "Wrong xform struct provided!"); return -EINVAL; } @@ -232,7 +232,7 @@ mrvl_crypto_set_cipher_session_parameters(struct mrvl_crypto_session *sess, if ((cipher_xform->cipher.algo > RTE_DIM(cipher_map)) || (cipher_map[cipher_xform->cipher.algo].supported != ALGO_SUPPORTED)) { - MRVL_CRYPTO_LOG_ERR("Cipher algorithm not supported!"); + MRVL_LOG(ERR, "Cipher algorithm not supported!"); return -EINVAL; } @@ -252,7 +252,7 @@ mrvl_crypto_set_cipher_session_parameters(struct mrvl_crypto_session *sess, /* Get max key length. */ if (cipher_xform->cipher.key.length > cipher_map[cipher_xform->cipher.algo].max_key_len) { - MRVL_CRYPTO_LOG_ERR("Wrong key length!"); + MRVL_LOG(ERR, "Wrong key length!"); return -EINVAL; } @@ -275,14 +275,14 @@ mrvl_crypto_set_auth_session_parameters(struct mrvl_crypto_session *sess, { /* Make sure we've got proper struct */ if (auth_xform->type != RTE_CRYPTO_SYM_XFORM_AUTH) { - MRVL_CRYPTO_LOG_ERR("Wrong xform struct provided!"); + MRVL_LOG(ERR, "Wrong xform struct provided!"); return -EINVAL; } /* See if map data is present and valid */ if ((auth_xform->auth.algo > RTE_DIM(auth_map)) || (auth_map[auth_xform->auth.algo].supported != ALGO_SUPPORTED)) { - MRVL_CRYPTO_LOG_ERR("Auth algorithm not supported!"); + MRVL_LOG(ERR, "Auth algorithm not supported!"); return -EINVAL; } @@ -314,7 +314,7 @@ mrvl_crypto_set_aead_session_parameters(struct mrvl_crypto_session *sess, { /* Make sure we've got proper struct */ if (aead_xform->type != RTE_CRYPTO_SYM_XFORM_AEAD) { - MRVL_CRYPTO_LOG_ERR("Wrong xform struct provided!"); + MRVL_LOG(ERR, "Wrong xform struct provided!"); return -EINVAL; } @@ -322,7 +322,7 @@ mrvl_crypto_set_aead_session_parameters(struct mrvl_crypto_session *sess, if ((aead_xform->aead.algo > RTE_DIM(aead_map)) || (aead_map[aead_xform->aead.algo].supported != ALGO_SUPPORTED)) { - MRVL_CRYPTO_LOG_ERR("AEAD algorithm not supported!"); + MRVL_LOG(ERR, "AEAD algorithm not supported!"); return -EINVAL; } @@ -340,7 +340,7 @@ mrvl_crypto_set_aead_session_parameters(struct mrvl_crypto_session *sess, /* Get max key length. */ if (aead_xform->aead.key.length > aead_map[aead_xform->aead.algo].max_key_len) { - MRVL_CRYPTO_LOG_ERR("Wrong key length!"); + MRVL_LOG(ERR, "Wrong key length!"); return -EINVAL; } @@ -405,21 +405,21 @@ mrvl_crypto_set_session_parameters(struct mrvl_crypto_session *sess, if ((cipher_xform != NULL) && (mrvl_crypto_set_cipher_session_parameters( sess, cipher_xform) < 0)) { - MRVL_CRYPTO_LOG_ERR("Invalid/unsupported cipher parameters"); + MRVL_LOG(ERR, "Invalid/unsupported cipher parameters!"); return -EINVAL; } if ((auth_xform != NULL) && (mrvl_crypto_set_auth_session_parameters( sess, auth_xform) < 0)) { - MRVL_CRYPTO_LOG_ERR("Invalid/unsupported auth parameters"); + MRVL_LOG(ERR, "Invalid/unsupported auth parameters!"); return -EINVAL; } if ((aead_xform != NULL) && (mrvl_crypto_set_aead_session_parameters( sess, aead_xform) < 0)) { - MRVL_CRYPTO_LOG_ERR("Invalid/unsupported aead parameters"); + MRVL_LOG(ERR, "Invalid/unsupported aead parameters!"); return -EINVAL; } @@ -457,8 +457,8 @@ mrvl_request_prepare(struct sam_cio_op_params *request, int i; if (unlikely(op->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) { - MRVL_CRYPTO_LOG_ERR("MRVL CRYPTO PMD only supports session " - "oriented requests, op (%p) is sessionless.", + MRVL_LOG(ERR, "MRVL CRYPTO PMD only supports session " + "oriented requests, op (%p) is sessionless!", op); return -EINVAL; } @@ -466,7 +466,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, sess = (struct mrvl_crypto_session *)get_sym_session_private_data( op->sym->session, cryptodev_driver_id); if (unlikely(sess == NULL)) { - MRVL_CRYPTO_LOG_ERR("Session was not created for this device"); + MRVL_LOG(ERR, "Session was not created for this device!"); return -EINVAL; } @@ -480,7 +480,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, * - Segmented destination buffer is not supported */ if ((segments_nb > 1) && (!op->sym->m_dst)) { - MRVL_CRYPTO_LOG_ERR("op->sym->m_dst = NULL!\n"); + MRVL_LOG(ERR, "op->sym->m_dst = NULL!"); return -1; } /* For non SG case: @@ -490,8 +490,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, dst_mbuf = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src; if (!rte_pktmbuf_is_contiguous(dst_mbuf)) { - MRVL_CRYPTO_LOG_ERR("Segmented destination buffer " - "not supported.\n"); + MRVL_LOG(ERR, "Segmented destination buffer not supported!"); return -1; } @@ -500,7 +499,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, /* Empty source. */ if (rte_pktmbuf_data_len(src_mbuf) == 0) { /* EIP does not support 0 length buffers. */ - MRVL_CRYPTO_LOG_ERR("Buffer length == 0 not supported!"); + MRVL_LOG(ERR, "Buffer length == 0 not supported!"); return -1; } src_bd[i].vaddr = rte_pktmbuf_mtod(src_mbuf, void *); @@ -516,7 +515,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, /* Make dst buffer fit at least source data. */ if (rte_pktmbuf_append(dst_mbuf, rte_pktmbuf_data_len(op->sym->m_src)) == NULL) { - MRVL_CRYPTO_LOG_ERR("Unable to set big enough dst buffer!"); + MRVL_LOG(ERR, "Unable to set big enough dst buffer!"); return -1; } } @@ -656,8 +655,7 @@ mrvl_crypto_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, src_bd[iter_ops].src_bd, &dst_bd[iter_ops], ops[iter_ops]) < 0) { - MRVL_CRYPTO_LOG_ERR( - "Error while parameters preparation!"); + MRVL_LOG(ERR, "Error while preparing parameters!"); qp->stats.enqueue_err_count++; ops[iter_ops]->status = RTE_CRYPTO_OP_STATUS_ERROR; @@ -735,12 +733,12 @@ mrvl_crypto_pmd_dequeue_burst(void *queue_pair, ops[i]->status = RTE_CRYPTO_OP_STATUS_SUCCESS; break; case SAM_CIO_ERR_ICV: - MRVL_CRYPTO_LOG_DBG("CIO returned SAM_CIO_ERR_ICV."); + MRVL_LOG(DEBUG, "CIO returned SAM_CIO_ERR_ICV."); ops[i]->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED; break; default: - MRVL_CRYPTO_LOG_DBG( - "CIO returned Error: %d", results[i].status); + MRVL_LOG(DEBUG, + "CIO returned Error: %d.", results[i].status); ops[i]->status = RTE_CRYPTO_OP_STATUS_ERROR; break; } @@ -771,7 +769,7 @@ cryptodev_mrvl_crypto_create(const char *name, dev = rte_cryptodev_pmd_create(name, &vdev->device, &init_params->common); if (dev == NULL) { - MRVL_CRYPTO_LOG_ERR("failed to create cryptodev vdev"); + MRVL_LOG(ERR, "Failed to create cryptodev vdev!"); goto init_error; } @@ -807,8 +805,8 @@ cryptodev_mrvl_crypto_create(const char *name, return 0; init_error: - MRVL_CRYPTO_LOG_ERR( - "driver %s: %s failed", init_params->common.name, __func__); + MRVL_LOG(ERR, + "Driver %s: %s failed!", init_params->common.name, __func__); cryptodev_mrvl_crypto_uninit(vdev); return ret; @@ -823,7 +821,7 @@ parse_integer_arg(const char *key __rte_unused, *i = atoi(value); if (*i < 0) { - MRVL_CRYPTO_LOG_ERR("Argument has to be positive.\n"); + MRVL_LOG(ERR, "Argument has to be positive!"); return -EINVAL; } @@ -838,9 +836,8 @@ parse_name_arg(const char *key __rte_unused, struct rte_cryptodev_pmd_init_params *params = extra_args; if (strlen(value) >= RTE_CRYPTODEV_NAME_MAX_LEN - 1) { - MRVL_CRYPTO_LOG_ERR("Invalid name %s, should be less than " - "%u bytes.\n", value, - RTE_CRYPTODEV_NAME_MAX_LEN - 1); + MRVL_LOG(ERR, "Invalid name %s, should be less than %u bytes!", + value, RTE_CRYPTODEV_NAME_MAX_LEN - 1); return -EINVAL; } @@ -932,9 +929,8 @@ cryptodev_mrvl_crypto_init(struct rte_vdev_device *vdev) ret = mrvl_pmd_parse_input_args(&init_params, args); if (ret) { - RTE_LOG(ERR, PMD, - "Failed to parse initialisation arguments[%s]\n", - args); + MRVL_LOG(ERR, "Failed to parse initialisation arguments[%s]!", + args); return -EINVAL; } @@ -956,9 +952,8 @@ cryptodev_mrvl_crypto_uninit(struct rte_vdev_device *vdev) if (name == NULL) return -EINVAL; - RTE_LOG(INFO, PMD, - "Closing Marvell crypto device %s on numa socket %u\n", - name, rte_socket_id()); + MRVL_LOG(INFO, "Closing Marvell crypto device %s on numa socket %u.", + name, rte_socket_id()); sam_deinit(); rte_mvep_deinit(MVEP_MOD_T_SAM); @@ -988,3 +983,8 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_MRVL_PMD, "socket_id=<int>"); RTE_PMD_REGISTER_CRYPTO_DRIVER(mrvl_crypto_drv, cryptodev_mrvl_pmd_drv.driver, cryptodev_driver_id); + +RTE_INIT(crypto_mrvl_init_log) +{ + mrvl_logtype_driver = rte_log_register("pmd.crypto.mvsam"); +} diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c index 62f5a2a..9956f05 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c +++ b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c @@ -657,7 +657,7 @@ mrvl_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, */ int num = sam_get_num_inst(); if (num == 0) { - MRVL_CRYPTO_LOG_ERR("No crypto engines detected.\n"); + MRVL_LOG(ERR, "No crypto engines detected!"); return -1; } @@ -741,7 +741,7 @@ mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev, int ret; if (sess == NULL) { - MRVL_CRYPTO_LOG_ERR("Invalid session struct."); + MRVL_LOG(ERR, "Invalid session struct!"); return -EINVAL; } @@ -752,7 +752,7 @@ mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev, ret = mrvl_crypto_set_session_parameters(sess_private_data, xform); if (ret != 0) { - MRVL_CRYPTO_LOG_ERR("Failed to configure session parameters."); + MRVL_LOG(ERR, "Failed to configure session parameters!"); /* Return session to mempool */ rte_mempool_put(mp, sess_private_data); @@ -764,7 +764,7 @@ mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev, mrvl_sess = (struct mrvl_crypto_session *)sess_private_data; if (sam_session_create(&mrvl_sess->sam_sess_params, &mrvl_sess->sam_sess) < 0) { - MRVL_CRYPTO_LOG_DBG("Failed to create session!"); + MRVL_LOG(DEBUG, "Failed to create session!"); return -EIO; } @@ -792,7 +792,7 @@ mrvl_crypto_pmd_sym_session_clear(struct rte_cryptodev *dev, if (mrvl_sess->sam_sess && sam_session_destroy(mrvl_sess->sam_sess) < 0) { - MRVL_CRYPTO_LOG_INFO("Error while destroying session!"); + MRVL_LOG(ERR, "Error while destroying session!"); } memset(sess, 0, sizeof(struct mrvl_crypto_session)); diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_private.h b/drivers/crypto/mvsam/rte_mrvl_pmd_private.h index 0689fc3..6f8cf56 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd_private.h +++ b/drivers/crypto/mvsam/rte_mrvl_pmd_private.h @@ -12,26 +12,13 @@ #define CRYPTODEV_NAME_MRVL_PMD crypto_mvsam /**< Marvell PMD device name */ -#define MRVL_CRYPTO_LOG_ERR(fmt, args...) \ - RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \ - RTE_STR(CRYPTODEV_NAME_MRVL_PMD), \ - __func__, __LINE__, ## args) - -#ifdef RTE_LIBRTE_PMD_MRVL_CRYPTO_DEBUG -#define MRVL_CRYPTO_LOG_INFO(fmt, args...) \ - RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \ - RTE_STR(CRYPTODEV_NAME_MRVL_PMD), \ - __func__, __LINE__, ## args) - -#define MRVL_CRYPTO_LOG_DBG(fmt, args...) \ - RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \ - RTE_STR(CRYPTODEV_NAME_MRVL_PMD), \ - __func__, __LINE__, ## args) - -#else -#define MRVL_CRYPTO_LOG_INFO(fmt, args...) -#define MRVL_CRYPTO_LOG_DBG(fmt, args...) -#endif +/** MRVL PMD LOGTYPE DRIVER */ +int mrvl_logtype_driver; + +#define MRVL_LOG(level, fmt, ...) \ + rte_log(RTE_LOG_ ## level, mrvl_logtype_driver, \ + "%s() line %u: " fmt "\n", __func__, __LINE__, \ + ## __VA_ARGS__) /** * Handy bits->bytes conversion macro. -- 2.7.4 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [dpdk-dev] [PATCH v2 0/3] crypto/mvsam: yet another round of features 2018-08-27 12:22 [dpdk-dev] [PATCH 0/3] crypto/mvsam: yet another round of features Tomasz Duszynski ` (2 preceding siblings ...) 2018-08-27 12:22 ` [dpdk-dev] [PATCH 3/3] crypto/mvsam: add dynamic logging support Tomasz Duszynski @ 2018-09-21 13:24 ` Andrzej Ostruszka 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 1/3] crypto/mvsam: add S/G support to crypto dirver Andrzej Ostruszka ` (3 more replies) 3 siblings, 4 replies; 11+ messages in thread From: Andrzej Ostruszka @ 2018-09-21 13:24 UTC (permalink / raw) To: dev; +Cc: mw, nadavh Following changes are introduced in this patch series: * Add S/G support. * Start using common/mvep for DMA memory initialization. * Add dynamic logging support. Note that 'crypto/mvsam: common use initialization' relies on 'net/mvpp2: use common code to initialize DMA' which is now on dpdk-next-net/master. v2: * rebased on top of next-net (some patches could not apply correctly) * in Makefiles for conditional testing 'findstring' used instead of 'filter' (it is slightly better for that purpose and agrees with pending NETA patches so it should make applying/rebasing easier). Dmitri Epshtein (1): crypto/mvsam: use common initialization Tomasz Duszynski (1): crypto/mvsam: add dynamic logging support Zyta Szpak (1): crypto/mvsam: add S/G support to crypto dirver config/common_base | 1 - drivers/common/Makefile | 4 +- drivers/crypto/mvsam/Makefile | 3 +- drivers/crypto/mvsam/meson.build | 2 +- drivers/crypto/mvsam/rte_mrvl_pmd.c | 193 +++++++++++++++++----------- drivers/crypto/mvsam/rte_mrvl_pmd_ops.c | 10 +- drivers/crypto/mvsam/rte_mrvl_pmd_private.h | 34 ++--- mk/rte.app.mk | 4 +- 8 files changed, 144 insertions(+), 107 deletions(-) -- 2.7.4 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [dpdk-dev] [PATCH v2 1/3] crypto/mvsam: add S/G support to crypto dirver 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 0/3] crypto/mvsam: yet another round of features Andrzej Ostruszka @ 2018-09-21 13:24 ` Andrzej Ostruszka 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 2/3] crypto/mvsam: use common initialization Andrzej Ostruszka ` (2 subsequent siblings) 3 siblings, 0 replies; 11+ messages in thread From: Andrzej Ostruszka @ 2018-09-21 13:24 UTC (permalink / raw) To: dev; +Cc: mw, nadavh, Zyta Szpak, Natalie Samsonov From: Zyta Szpak <zr@semihalf.com> The patch adds support for chained source mbufs given to crypto operations. The crypto engine accepts source buffer containing a number of segments. The destination buffer stays the same - always one segment. On decryption, EIP engine will look for digest at 'auth_icv_offset' offset in SRC buffer.It must be placed in the last segment and the offset must be set to reach digest in the last segment. If application doesn't placed digest in source mbuf, driver try to copy it to a last segment. Signed-off-by: Zyta Szpak <zr@semihalf.com> Signed-off-by: Natalie Samsonov <nsamsono@marvell.com> Reviewed-by: Dmitri Epshtein <dima@marvell.com> --- drivers/crypto/mvsam/rte_mrvl_pmd.c | 96 +++++++++++++++++++++-------- drivers/crypto/mvsam/rte_mrvl_pmd_private.h | 7 +++ 2 files changed, 76 insertions(+), 27 deletions(-) diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c index 73eff75..977e478 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd.c +++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c @@ -437,8 +437,10 @@ mrvl_request_prepare(struct sam_cio_op_params *request, struct rte_crypto_op *op) { struct mrvl_crypto_session *sess; - struct rte_mbuf *dst_mbuf; + struct rte_mbuf *src_mbuf, *dst_mbuf; + uint16_t segments_nb; uint8_t *digest; + int i; if (unlikely(op->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) { MRVL_CRYPTO_LOG_ERR("MRVL CRYPTO PMD only supports session " @@ -454,29 +456,47 @@ mrvl_request_prepare(struct sam_cio_op_params *request, return -EINVAL; } - /* + request->sa = sess->sam_sess; + request->cookie = op; + + src_mbuf = op->sym->m_src; + segments_nb = src_mbuf->nb_segs; + /* The following conditions must be met: + * - Destination buffer is required when segmented source buffer + * - Segmented destination buffer is not supported + */ + if ((segments_nb > 1) && (!op->sym->m_dst)) { + MRVL_CRYPTO_LOG_ERR("op->sym->m_dst = NULL!\n"); + return -1; + } + /* For non SG case: * If application delivered us null dst buffer, it means it expects * us to deliver the result in src buffer. */ dst_mbuf = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src; - request->sa = sess->sam_sess; - request->cookie = op; - - /* Single buffers only, sorry. */ - request->num_bufs = 1; - request->src = src_bd; - src_bd->vaddr = rte_pktmbuf_mtod(op->sym->m_src, void *); - src_bd->paddr = rte_pktmbuf_iova(op->sym->m_src); - src_bd->len = rte_pktmbuf_data_len(op->sym->m_src); - - /* Empty source. */ - if (rte_pktmbuf_data_len(op->sym->m_src) == 0) { - /* EIP does not support 0 length buffers. */ - MRVL_CRYPTO_LOG_ERR("Buffer length == 0 not supported!"); + if (!rte_pktmbuf_is_contiguous(dst_mbuf)) { + MRVL_CRYPTO_LOG_ERR("Segmented destination buffer " + "not supported.\n"); return -1; } + request->num_bufs = segments_nb; + for (i = 0; i < segments_nb; i++) { + /* Empty source. */ + if (rte_pktmbuf_data_len(src_mbuf) == 0) { + /* EIP does not support 0 length buffers. */ + MRVL_CRYPTO_LOG_ERR("Buffer length == 0 not supported!"); + return -1; + } + src_bd[i].vaddr = rte_pktmbuf_mtod(src_mbuf, void *); + src_bd[i].paddr = rte_pktmbuf_iova(src_mbuf); + src_bd[i].len = rte_pktmbuf_data_len(src_mbuf); + + src_mbuf = src_mbuf->next; + } + request->src = src_bd; + /* Empty destination. */ if (rte_pktmbuf_data_len(dst_mbuf) == 0) { /* Make dst buffer fit at least source data. */ @@ -527,7 +547,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, /* * EIP supports only scenarios where ICV(digest buffer) is placed at - * auth_icv_offset. Any other placement means risking errors. + * auth_icv_offset. */ if (sess->sam_sess_params.dir == SAM_DIR_ENCRYPT) { /* @@ -536,17 +556,36 @@ mrvl_request_prepare(struct sam_cio_op_params *request, */ if (rte_pktmbuf_mtod_offset( dst_mbuf, uint8_t *, - request->auth_icv_offset) == digest) { + request->auth_icv_offset) == digest) return 0; - } } else {/* sess->sam_sess_params.dir == SAM_DIR_DECRYPT */ /* * EIP will look for digest at auth_icv_offset - * offset in SRC buffer. + * offset in SRC buffer. It must be placed in the last + * segment and the offset must be set to reach digest + * in the last segment */ - if (rte_pktmbuf_mtod_offset( - op->sym->m_src, uint8_t *, - request->auth_icv_offset) == digest) { + struct rte_mbuf *last_seg = op->sym->m_src; + uint32_t d_offset = request->auth_icv_offset; + u32 d_size = sess->sam_sess_params.u.basic.auth_icv_len; + unsigned char *d_ptr; + + /* Find the last segment and the offset for the last segment */ + while ((last_seg->next != NULL) && + (d_offset >= last_seg->data_len)) { + d_offset -= last_seg->data_len; + last_seg = last_seg->next; + } + + if (rte_pktmbuf_mtod_offset(last_seg, uint8_t *, + d_offset) == digest) + return 0; + + /* copy digest to last segment */ + if (last_seg->buf_len >= (d_size + d_offset)) { + d_ptr = (unsigned char *)last_seg->buf_addr + + d_offset; + rte_memcpy(d_ptr, digest, d_size); return 0; } } @@ -582,11 +621,10 @@ mrvl_crypto_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, int ret; struct sam_cio_op_params requests[nb_ops]; /* - * DPDK uses single fragment buffers, so we can KISS descriptors. * SAM does not store bd pointers, so on-stack scope will be enough. */ - struct sam_buf_info src_bd[nb_ops]; - struct sam_buf_info dst_bd[nb_ops]; + struct mrvl_crypto_src_table src_bd[nb_ops]; + struct sam_buf_info dst_bd[nb_ops]; struct mrvl_crypto_qp *qp = (struct mrvl_crypto_qp *)queue_pair; if (nb_ops == 0) @@ -594,11 +632,14 @@ mrvl_crypto_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, /* Prepare the burst. */ memset(&requests, 0, sizeof(requests)); + memset(&src_bd, 0, sizeof(src_bd)); /* Iterate through */ for (; iter_ops < nb_ops; ++iter_ops) { + /* store the op id for debug */ + src_bd[iter_ops].iter_ops = iter_ops; if (mrvl_request_prepare(&requests[iter_ops], - &src_bd[iter_ops], + src_bd[iter_ops].src_bd, &dst_bd[iter_ops], ops[iter_ops]) < 0) { MRVL_CRYPTO_LOG_ERR( @@ -752,6 +793,7 @@ cryptodev_mrvl_crypto_create(const char *name, sam_params.max_num_sessions = internals->max_nb_sessions; + /* sam_set_debug_flags(3); */ return sam_init(&sam_params); init_error: diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_private.h b/drivers/crypto/mvsam/rte_mrvl_pmd_private.h index c16d95b..0689fc3 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd_private.h +++ b/drivers/crypto/mvsam/rte_mrvl_pmd_private.h @@ -38,6 +38,8 @@ */ #define BITS2BYTES(x) ((x) >> 3) +#define MRVL_MAX_SEGMENTS 16 + /** The operation order mode enumerator. */ enum mrvl_crypto_chain_order { MRVL_CRYPTO_CHAIN_CIPHER_ONLY, @@ -84,6 +86,11 @@ struct mrvl_crypto_session { uint16_t cipher_iv_offset; } __rte_cache_aligned; +struct mrvl_crypto_src_table { + uint16_t iter_ops; + struct sam_buf_info src_bd[MRVL_MAX_SEGMENTS]; +} __rte_cache_aligned; + /** Set and validate MRVL crypto session parameters */ extern int mrvl_crypto_set_session_parameters(struct mrvl_crypto_session *sess, -- 2.7.4 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [dpdk-dev] [PATCH v2 2/3] crypto/mvsam: use common initialization 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 0/3] crypto/mvsam: yet another round of features Andrzej Ostruszka 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 1/3] crypto/mvsam: add S/G support to crypto dirver Andrzej Ostruszka @ 2018-09-21 13:24 ` Andrzej Ostruszka 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 3/3] crypto/mvsam: add dynamic logging support Andrzej Ostruszka 2018-10-01 13:26 ` [dpdk-dev] [PATCH v2 0/3] crypto/mvsam: yet another round of features Akhil Goyal 3 siblings, 0 replies; 11+ messages in thread From: Andrzej Ostruszka @ 2018-09-21 13:24 UTC (permalink / raw) To: dev; +Cc: mw, nadavh, Dmitri Epshtein, Tomasz Duszynski From: Dmitri Epshtein <dima@marvell.com> Use common initialization to reduce boilerplate code. Signed-off-by: Dmitri Epshtein <dima@marvell.com> Signed-off-by: Tomasz Duszynski <tdu@semihalf.com> Reviewed-by: Natalie Samsonov <nsamsono@marvell.com> --- drivers/common/Makefile | 4 +++- drivers/crypto/mvsam/Makefile | 3 ++- drivers/crypto/mvsam/meson.build | 2 +- drivers/crypto/mvsam/rte_mrvl_pmd.c | 31 ++++++++++++++----------------- mk/rte.app.mk | 4 +++- 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/common/Makefile b/drivers/common/Makefile index 5f72da0..0859601 100644 --- a/drivers/common/Makefile +++ b/drivers/common/Makefile @@ -8,7 +8,9 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF)$(CONFIG_RTE_LIBRTE_OCTEONTX_MEMPOO DIRS-y += octeontx endif -ifeq ($(CONFIG_RTE_LIBRTE_MVPP2_PMD),y) +MVEP-y += $(CONFIG_RTE_LIBRTE_MVPP2_PMD) +MVEP-y += $(CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO) +ifneq (,$(findstring y,$(MVEP-y))) DIRS-y += mvep endif diff --git a/drivers/crypto/mvsam/Makefile b/drivers/crypto/mvsam/Makefile index c3dc72c..9850fda 100644 --- a/drivers/crypto/mvsam/Makefile +++ b/drivers/crypto/mvsam/Makefile @@ -19,6 +19,7 @@ LIB = librte_pmd_mvsam_crypto.a # build flags CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -I$(RTE_SDK)/drivers/common/mvep CFLAGS += -I$(LIBMUSDK_PATH)/include CFLAGS += -DMVCONF_TYPES_PUBLIC CFLAGS += -DMVCONF_DMA_PHYS_ADDR_T_PUBLIC @@ -33,7 +34,7 @@ EXPORT_MAP := rte_pmd_mvsam_version.map LDLIBS += -L$(LIBMUSDK_PATH)/lib -lmusdk LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool LDLIBS += -lrte_cryptodev -LDLIBS += -lrte_bus_vdev +LDLIBS += -lrte_bus_vdev -lrte_common_mvep # library source files SRCS-$(CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO) += rte_mrvl_pmd.c diff --git a/drivers/crypto/mvsam/meson.build b/drivers/crypto/mvsam/meson.build index 3c8ea3c..f1c8796 100644 --- a/drivers/crypto/mvsam/meson.build +++ b/drivers/crypto/mvsam/meson.build @@ -18,4 +18,4 @@ endif sources = files('rte_mrvl_pmd.c', 'rte_mrvl_pmd_ops.c') -deps += ['bus_vdev'] +deps += ['bus_vdev', 'common_mvep'] diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c index 977e478..35dd659 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd.c +++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c @@ -11,11 +11,11 @@ #include <rte_bus_vdev.h> #include <rte_malloc.h> #include <rte_cpuflags.h> +#include <rte_kvargs.h> +#include <rte_mvep_common.h> #include "rte_mrvl_pmd_private.h" -#define MRVL_MUSDK_DMA_MEMSIZE 41943040 - #define MRVL_PMD_MAX_NB_SESS_ARG ("max_nb_sessions") #define MRVL_PMD_DEFAULT_MAX_NB_SESSIONS 2048 @@ -752,7 +752,7 @@ cryptodev_mrvl_crypto_create(const char *name, struct rte_cryptodev *dev; struct mrvl_crypto_private *internals; struct sam_init_params sam_params; - int ret; + int ret = -EINVAL; dev = rte_cryptodev_pmd_create(name, &vdev->device, &init_params->common); @@ -778,30 +778,26 @@ cryptodev_mrvl_crypto_create(const char *name, internals->max_nb_qpairs = init_params->common.max_nb_queue_pairs; internals->max_nb_sessions = init_params->max_nb_sessions; - /* - * ret == -EEXIST is correct, it means DMA - * has been already initialized. - */ - ret = mv_sys_dma_mem_init(MRVL_MUSDK_DMA_MEMSIZE); - if (ret < 0) { - if (ret != -EEXIST) - return ret; - - MRVL_CRYPTO_LOG_INFO( - "DMA memory has been already initialized by a different driver."); - } + ret = rte_mvep_init(MVEP_MOD_T_SAM, NULL); + if (ret) + goto init_error; sam_params.max_num_sessions = internals->max_nb_sessions; /* sam_set_debug_flags(3); */ - return sam_init(&sam_params); + + ret = sam_init(&sam_params); + if (ret) + goto init_error; + + return 0; init_error: MRVL_CRYPTO_LOG_ERR( "driver %s: %s failed", init_params->common.name, __func__); cryptodev_mrvl_crypto_uninit(vdev); - return -EFAULT; + return ret; } /** Parse integer from integer argument */ @@ -951,6 +947,7 @@ cryptodev_mrvl_crypto_uninit(struct rte_vdev_device *vdev) name, rte_socket_id()); sam_deinit(); + rte_mvep_deinit(MVEP_MOD_T_SAM); cryptodev = rte_cryptodev_pmd_get_named_dev(name); if (cryptodev == NULL) diff --git a/mk/rte.app.mk b/mk/rte.app.mk index 899d51a..4278ebb 100644 --- a/mk/rte.app.mk +++ b/mk/rte.app.mk @@ -98,7 +98,9 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF)$(CONFIG_RTE_LIBRTE_OCTEONTX_MEMPOO _LDLIBS-y += -lrte_common_octeontx endif -ifeq ($(CONFIG_RTE_LIBRTE_MVPP2_PMD),y) +MVEP-y += $(CONFIG_RTE_LIBRTE_MVPP2_PMD) +MVEP-y += $(CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO) +ifneq (,$(findstring y,$(MVEP-y))) _LDLIBS-y += -lrte_common_mvep -L$(LIBMUSDK_PATH)/lib -lmusdk endif -- 2.7.4 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [dpdk-dev] [PATCH v2 3/3] crypto/mvsam: add dynamic logging support 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 0/3] crypto/mvsam: yet another round of features Andrzej Ostruszka 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 1/3] crypto/mvsam: add S/G support to crypto dirver Andrzej Ostruszka 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 2/3] crypto/mvsam: use common initialization Andrzej Ostruszka @ 2018-09-21 13:24 ` Andrzej Ostruszka 2018-10-01 13:26 ` [dpdk-dev] [PATCH v2 0/3] crypto/mvsam: yet another round of features Akhil Goyal 3 siblings, 0 replies; 11+ messages in thread From: Andrzej Ostruszka @ 2018-09-21 13:24 UTC (permalink / raw) To: dev; +Cc: mw, nadavh, Tomasz Duszynski From: Tomasz Duszynski <tdu@semihalf.com> Add dynamic logging support to mvsam crypto PMD. Signed-off-by: Tomasz Duszynski <tdu@semihalf.com> --- config/common_base | 1 - drivers/crypto/mvsam/rte_mrvl_pmd.c | 74 ++++++++++++++--------------- drivers/crypto/mvsam/rte_mrvl_pmd_ops.c | 10 ++-- drivers/crypto/mvsam/rte_mrvl_pmd_private.h | 27 +++-------- 4 files changed, 49 insertions(+), 63 deletions(-) diff --git a/config/common_base b/config/common_base index 155c7d4..61c7f6d 100644 --- a/config/common_base +++ b/config/common_base @@ -559,7 +559,6 @@ CONFIG_RTE_LIBRTE_PMD_CCP=n # Compile PMD for Marvell Crypto device # CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO=n -CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO_DEBUG=n # # Compile generic security library diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c index 35dd659..2afdd3b 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd.c +++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c @@ -210,7 +210,7 @@ mrvl_crypto_set_cipher_session_parameters(struct mrvl_crypto_session *sess, { /* Make sure we've got proper struct */ if (cipher_xform->type != RTE_CRYPTO_SYM_XFORM_CIPHER) { - MRVL_CRYPTO_LOG_ERR("Wrong xform struct provided!"); + MRVL_LOG(ERR, "Wrong xform struct provided!"); return -EINVAL; } @@ -218,7 +218,7 @@ mrvl_crypto_set_cipher_session_parameters(struct mrvl_crypto_session *sess, if ((cipher_xform->cipher.algo > RTE_DIM(cipher_map)) || (cipher_map[cipher_xform->cipher.algo].supported != ALGO_SUPPORTED)) { - MRVL_CRYPTO_LOG_ERR("Cipher algorithm not supported!"); + MRVL_LOG(ERR, "Cipher algorithm not supported!"); return -EINVAL; } @@ -238,7 +238,7 @@ mrvl_crypto_set_cipher_session_parameters(struct mrvl_crypto_session *sess, /* Get max key length. */ if (cipher_xform->cipher.key.length > cipher_map[cipher_xform->cipher.algo].max_key_len) { - MRVL_CRYPTO_LOG_ERR("Wrong key length!"); + MRVL_LOG(ERR, "Wrong key length!"); return -EINVAL; } @@ -261,14 +261,14 @@ mrvl_crypto_set_auth_session_parameters(struct mrvl_crypto_session *sess, { /* Make sure we've got proper struct */ if (auth_xform->type != RTE_CRYPTO_SYM_XFORM_AUTH) { - MRVL_CRYPTO_LOG_ERR("Wrong xform struct provided!"); + MRVL_LOG(ERR, "Wrong xform struct provided!"); return -EINVAL; } /* See if map data is present and valid */ if ((auth_xform->auth.algo > RTE_DIM(auth_map)) || (auth_map[auth_xform->auth.algo].supported != ALGO_SUPPORTED)) { - MRVL_CRYPTO_LOG_ERR("Auth algorithm not supported!"); + MRVL_LOG(ERR, "Auth algorithm not supported!"); return -EINVAL; } @@ -300,7 +300,7 @@ mrvl_crypto_set_aead_session_parameters(struct mrvl_crypto_session *sess, { /* Make sure we've got proper struct */ if (aead_xform->type != RTE_CRYPTO_SYM_XFORM_AEAD) { - MRVL_CRYPTO_LOG_ERR("Wrong xform struct provided!"); + MRVL_LOG(ERR, "Wrong xform struct provided!"); return -EINVAL; } @@ -308,7 +308,7 @@ mrvl_crypto_set_aead_session_parameters(struct mrvl_crypto_session *sess, if ((aead_xform->aead.algo > RTE_DIM(aead_map)) || (aead_map[aead_xform->aead.algo].supported != ALGO_SUPPORTED)) { - MRVL_CRYPTO_LOG_ERR("AEAD algorithm not supported!"); + MRVL_LOG(ERR, "AEAD algorithm not supported!"); return -EINVAL; } @@ -326,7 +326,7 @@ mrvl_crypto_set_aead_session_parameters(struct mrvl_crypto_session *sess, /* Get max key length. */ if (aead_xform->aead.key.length > aead_map[aead_xform->aead.algo].max_key_len) { - MRVL_CRYPTO_LOG_ERR("Wrong key length!"); + MRVL_LOG(ERR, "Wrong key length!"); return -EINVAL; } @@ -391,21 +391,21 @@ mrvl_crypto_set_session_parameters(struct mrvl_crypto_session *sess, if ((cipher_xform != NULL) && (mrvl_crypto_set_cipher_session_parameters( sess, cipher_xform) < 0)) { - MRVL_CRYPTO_LOG_ERR("Invalid/unsupported cipher parameters"); + MRVL_LOG(ERR, "Invalid/unsupported cipher parameters!"); return -EINVAL; } if ((auth_xform != NULL) && (mrvl_crypto_set_auth_session_parameters( sess, auth_xform) < 0)) { - MRVL_CRYPTO_LOG_ERR("Invalid/unsupported auth parameters"); + MRVL_LOG(ERR, "Invalid/unsupported auth parameters!"); return -EINVAL; } if ((aead_xform != NULL) && (mrvl_crypto_set_aead_session_parameters( sess, aead_xform) < 0)) { - MRVL_CRYPTO_LOG_ERR("Invalid/unsupported aead parameters"); + MRVL_LOG(ERR, "Invalid/unsupported aead parameters!"); return -EINVAL; } @@ -443,8 +443,8 @@ mrvl_request_prepare(struct sam_cio_op_params *request, int i; if (unlikely(op->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) { - MRVL_CRYPTO_LOG_ERR("MRVL CRYPTO PMD only supports session " - "oriented requests, op (%p) is sessionless.", + MRVL_LOG(ERR, "MRVL CRYPTO PMD only supports session " + "oriented requests, op (%p) is sessionless!", op); return -EINVAL; } @@ -452,7 +452,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, sess = (struct mrvl_crypto_session *)get_sym_session_private_data( op->sym->session, cryptodev_driver_id); if (unlikely(sess == NULL)) { - MRVL_CRYPTO_LOG_ERR("Session was not created for this device"); + MRVL_LOG(ERR, "Session was not created for this device!"); return -EINVAL; } @@ -466,7 +466,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, * - Segmented destination buffer is not supported */ if ((segments_nb > 1) && (!op->sym->m_dst)) { - MRVL_CRYPTO_LOG_ERR("op->sym->m_dst = NULL!\n"); + MRVL_LOG(ERR, "op->sym->m_dst = NULL!"); return -1; } /* For non SG case: @@ -476,8 +476,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, dst_mbuf = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src; if (!rte_pktmbuf_is_contiguous(dst_mbuf)) { - MRVL_CRYPTO_LOG_ERR("Segmented destination buffer " - "not supported.\n"); + MRVL_LOG(ERR, "Segmented destination buffer not supported!"); return -1; } @@ -486,7 +485,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, /* Empty source. */ if (rte_pktmbuf_data_len(src_mbuf) == 0) { /* EIP does not support 0 length buffers. */ - MRVL_CRYPTO_LOG_ERR("Buffer length == 0 not supported!"); + MRVL_LOG(ERR, "Buffer length == 0 not supported!"); return -1; } src_bd[i].vaddr = rte_pktmbuf_mtod(src_mbuf, void *); @@ -502,7 +501,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request, /* Make dst buffer fit at least source data. */ if (rte_pktmbuf_append(dst_mbuf, rte_pktmbuf_data_len(op->sym->m_src)) == NULL) { - MRVL_CRYPTO_LOG_ERR("Unable to set big enough dst buffer!"); + MRVL_LOG(ERR, "Unable to set big enough dst buffer!"); return -1; } } @@ -642,8 +641,7 @@ mrvl_crypto_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, src_bd[iter_ops].src_bd, &dst_bd[iter_ops], ops[iter_ops]) < 0) { - MRVL_CRYPTO_LOG_ERR( - "Error while parameters preparation!"); + MRVL_LOG(ERR, "Error while preparing parameters!"); qp->stats.enqueue_err_count++; ops[iter_ops]->status = RTE_CRYPTO_OP_STATUS_ERROR; @@ -721,12 +719,12 @@ mrvl_crypto_pmd_dequeue_burst(void *queue_pair, ops[i]->status = RTE_CRYPTO_OP_STATUS_SUCCESS; break; case SAM_CIO_ERR_ICV: - MRVL_CRYPTO_LOG_DBG("CIO returned SAM_CIO_ERR_ICV."); + MRVL_LOG(DEBUG, "CIO returned SAM_CIO_ERR_ICV."); ops[i]->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED; break; default: - MRVL_CRYPTO_LOG_DBG( - "CIO returned Error: %d", results[i].status); + MRVL_LOG(DEBUG, + "CIO returned Error: %d.", results[i].status); ops[i]->status = RTE_CRYPTO_OP_STATUS_ERROR; break; } @@ -757,7 +755,7 @@ cryptodev_mrvl_crypto_create(const char *name, dev = rte_cryptodev_pmd_create(name, &vdev->device, &init_params->common); if (dev == NULL) { - MRVL_CRYPTO_LOG_ERR("failed to create cryptodev vdev"); + MRVL_LOG(ERR, "Failed to create cryptodev vdev!"); goto init_error; } @@ -793,8 +791,8 @@ cryptodev_mrvl_crypto_create(const char *name, return 0; init_error: - MRVL_CRYPTO_LOG_ERR( - "driver %s: %s failed", init_params->common.name, __func__); + MRVL_LOG(ERR, + "Driver %s: %s failed!", init_params->common.name, __func__); cryptodev_mrvl_crypto_uninit(vdev); return ret; @@ -809,7 +807,7 @@ parse_integer_arg(const char *key __rte_unused, *i = atoi(value); if (*i < 0) { - MRVL_CRYPTO_LOG_ERR("Argument has to be positive.\n"); + MRVL_LOG(ERR, "Argument has to be positive!"); return -EINVAL; } @@ -824,9 +822,8 @@ parse_name_arg(const char *key __rte_unused, struct rte_cryptodev_pmd_init_params *params = extra_args; if (strlen(value) >= RTE_CRYPTODEV_NAME_MAX_LEN - 1) { - MRVL_CRYPTO_LOG_ERR("Invalid name %s, should be less than " - "%u bytes.\n", value, - RTE_CRYPTODEV_NAME_MAX_LEN - 1); + MRVL_LOG(ERR, "Invalid name %s, should be less than %u bytes!", + value, RTE_CRYPTODEV_NAME_MAX_LEN - 1); return -EINVAL; } @@ -918,9 +915,8 @@ cryptodev_mrvl_crypto_init(struct rte_vdev_device *vdev) ret = mrvl_pmd_parse_input_args(&init_params, args); if (ret) { - RTE_LOG(ERR, PMD, - "Failed to parse initialisation arguments[%s]\n", - args); + MRVL_LOG(ERR, "Failed to parse initialisation arguments[%s]!", + args); return -EINVAL; } @@ -942,9 +938,8 @@ cryptodev_mrvl_crypto_uninit(struct rte_vdev_device *vdev) if (name == NULL) return -EINVAL; - RTE_LOG(INFO, PMD, - "Closing Marvell crypto device %s on numa socket %u\n", - name, rte_socket_id()); + MRVL_LOG(INFO, "Closing Marvell crypto device %s on numa socket %u.", + name, rte_socket_id()); sam_deinit(); rte_mvep_deinit(MVEP_MOD_T_SAM); @@ -974,3 +969,8 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_MRVL_PMD, "socket_id=<int>"); RTE_PMD_REGISTER_CRYPTO_DRIVER(mrvl_crypto_drv, cryptodev_mrvl_pmd_drv.driver, cryptodev_driver_id); + +RTE_INIT(crypto_mrvl_init_log) +{ + mrvl_logtype_driver = rte_log_register("pmd.crypto.mvsam"); +} diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c index c045562..ba6eef3 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c +++ b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c @@ -551,7 +551,7 @@ mrvl_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, */ int num = sam_get_num_inst(); if (num == 0) { - MRVL_CRYPTO_LOG_ERR("No crypto engines detected.\n"); + MRVL_LOG(ERR, "No crypto engines detected!"); return -1; } @@ -635,7 +635,7 @@ mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev, int ret; if (sess == NULL) { - MRVL_CRYPTO_LOG_ERR("Invalid session struct."); + MRVL_LOG(ERR, "Invalid session struct!"); return -EINVAL; } @@ -646,7 +646,7 @@ mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev, ret = mrvl_crypto_set_session_parameters(sess_private_data, xform); if (ret != 0) { - MRVL_CRYPTO_LOG_ERR("Failed to configure session parameters."); + MRVL_LOG(ERR, "Failed to configure session parameters!"); /* Return session to mempool */ rte_mempool_put(mp, sess_private_data); @@ -658,7 +658,7 @@ mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev, mrvl_sess = (struct mrvl_crypto_session *)sess_private_data; if (sam_session_create(&mrvl_sess->sam_sess_params, &mrvl_sess->sam_sess) < 0) { - MRVL_CRYPTO_LOG_DBG("Failed to create session!"); + MRVL_LOG(DEBUG, "Failed to create session!"); return -EIO; } @@ -686,7 +686,7 @@ mrvl_crypto_pmd_sym_session_clear(struct rte_cryptodev *dev, if (mrvl_sess->sam_sess && sam_session_destroy(mrvl_sess->sam_sess) < 0) { - MRVL_CRYPTO_LOG_INFO("Error while destroying session!"); + MRVL_LOG(ERR, "Error while destroying session!"); } memset(sess, 0, sizeof(struct mrvl_crypto_session)); diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_private.h b/drivers/crypto/mvsam/rte_mrvl_pmd_private.h index 0689fc3..6f8cf56 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd_private.h +++ b/drivers/crypto/mvsam/rte_mrvl_pmd_private.h @@ -12,26 +12,13 @@ #define CRYPTODEV_NAME_MRVL_PMD crypto_mvsam /**< Marvell PMD device name */ -#define MRVL_CRYPTO_LOG_ERR(fmt, args...) \ - RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \ - RTE_STR(CRYPTODEV_NAME_MRVL_PMD), \ - __func__, __LINE__, ## args) - -#ifdef RTE_LIBRTE_PMD_MRVL_CRYPTO_DEBUG -#define MRVL_CRYPTO_LOG_INFO(fmt, args...) \ - RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \ - RTE_STR(CRYPTODEV_NAME_MRVL_PMD), \ - __func__, __LINE__, ## args) - -#define MRVL_CRYPTO_LOG_DBG(fmt, args...) \ - RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \ - RTE_STR(CRYPTODEV_NAME_MRVL_PMD), \ - __func__, __LINE__, ## args) - -#else -#define MRVL_CRYPTO_LOG_INFO(fmt, args...) -#define MRVL_CRYPTO_LOG_DBG(fmt, args...) -#endif +/** MRVL PMD LOGTYPE DRIVER */ +int mrvl_logtype_driver; + +#define MRVL_LOG(level, fmt, ...) \ + rte_log(RTE_LOG_ ## level, mrvl_logtype_driver, \ + "%s() line %u: " fmt "\n", __func__, __LINE__, \ + ## __VA_ARGS__) /** * Handy bits->bytes conversion macro. -- 2.7.4 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [dpdk-dev] [PATCH v2 0/3] crypto/mvsam: yet another round of features 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 0/3] crypto/mvsam: yet another round of features Andrzej Ostruszka ` (2 preceding siblings ...) 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 3/3] crypto/mvsam: add dynamic logging support Andrzej Ostruszka @ 2018-10-01 13:26 ` Akhil Goyal 3 siblings, 0 replies; 11+ messages in thread From: Akhil Goyal @ 2018-10-01 13:26 UTC (permalink / raw) To: Andrzej Ostruszka, dev; +Cc: mw, nadavh On 9/21/2018 6:54 PM, Andrzej Ostruszka wrote: > Following changes are introduced in this patch series: > > * Add S/G support. > * Start using common/mvep for DMA memory initialization. > * Add dynamic logging support. > > Note that 'crypto/mvsam: common use initialization' relies on > 'net/mvpp2: use common code to initialize DMA' which is now on > dpdk-next-net/master. > > v2: > * rebased on top of next-net (some patches could not apply correctly) > * in Makefiles for conditional testing 'findstring' used instead of > 'filter' (it is slightly better for that purpose and agrees with > pending NETA patches so it should make applying/rebasing easier). > > Dmitri Epshtein (1): > crypto/mvsam: use common initialization > > Tomasz Duszynski (1): > crypto/mvsam: add dynamic logging support > > Zyta Szpak (1): > crypto/mvsam: add S/G support to crypto dirver > > config/common_base | 1 - > drivers/common/Makefile | 4 +- > drivers/crypto/mvsam/Makefile | 3 +- > drivers/crypto/mvsam/meson.build | 2 +- > drivers/crypto/mvsam/rte_mrvl_pmd.c | 193 +++++++++++++++++----------- > drivers/crypto/mvsam/rte_mrvl_pmd_ops.c | 10 +- > drivers/crypto/mvsam/rte_mrvl_pmd_private.h | 34 ++--- > mk/rte.app.mk | 4 +- > 8 files changed, 144 insertions(+), 107 deletions(-) > Series applied to dpdk-next-crypto Thanks ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2018-10-01 13:27 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-08-27 12:22 [dpdk-dev] [PATCH 0/3] crypto/mvsam: yet another round of features Tomasz Duszynski 2018-08-27 12:22 ` [dpdk-dev] [PATCH 1/3] crypto/mvsam: add S/G support to crypto dirver Tomasz Duszynski 2018-09-17 14:07 ` Akhil Goyal 2018-09-21 13:18 ` Andrzej Ostruszka 2018-08-27 12:22 ` [dpdk-dev] [PATCH 2/3] crypto/mvsam: use common initialization Tomasz Duszynski 2018-08-27 12:22 ` [dpdk-dev] [PATCH 3/3] crypto/mvsam: add dynamic logging support Tomasz Duszynski 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 0/3] crypto/mvsam: yet another round of features Andrzej Ostruszka 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 1/3] crypto/mvsam: add S/G support to crypto dirver Andrzej Ostruszka 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 2/3] crypto/mvsam: use common initialization Andrzej Ostruszka 2018-09-21 13:24 ` [dpdk-dev] [PATCH v2 3/3] crypto/mvsam: add dynamic logging support Andrzej Ostruszka 2018-10-01 13:26 ` [dpdk-dev] [PATCH v2 0/3] crypto/mvsam: yet another round of features Akhil Goyal
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).