Show a patch.

GET /api/patches/45104/
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 45104,
    "url": "http://patches.dpdk.org/api/patches/45104/",
    "web_url": "http://patches.dpdk.org/patch/45104/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk"
    },
    "msgid": "<1537536294-16703-2-git-send-email-amo@semihalf.com>",
    "date": "2018-09-21T13:24:52",
    "name": "[v2,1/3] crypto/mvsam: add S/G support to crypto dirver",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "2490734dba6be58e5b6b38658af82ce07de5ab83",
    "submitter": {
        "id": 1112,
        "url": "http://patches.dpdk.org/api/people/1112/",
        "name": "Andrzej Ostruszka",
        "email": "amo@semihalf.com"
    },
    "delegate": {
        "id": 6690,
        "url": "http://patches.dpdk.org/api/users/6690/",
        "username": "akhil",
        "first_name": "akhil",
        "last_name": "goyal",
        "email": "akhil.goyal@nxp.com"
    },
    "mbox": "http://patches.dpdk.org/patch/45104/mbox/",
    "series": [
        {
            "id": 1440,
            "url": "http://patches.dpdk.org/api/series/1440/",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1440",
            "date": "2018-09-21T13:24:51",
            "name": "crypto/mvsam: yet another round of features",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/1440/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/45104/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/45104/checks/",
    "tags": {},
    "headers": {
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "X-Gm-Message-State": "ABuFfog5EvqASKo58bwy9EW2i2DtktNnTZj/T0Dl+lo4ZvmHWG+p0yaj\n\tIyMANQwcdg9Jt9+BwQKiU+CxUaLKijU=",
        "X-Google-Smtp-Source": "ACcGV62HOtnniMSGPeSU+ubBFuUMnIVbVHeWAA1AQ4R/hWHGNtwy8YV7BfzBU5J1yXwfu888IPFgDw==",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "X-BeenThere": "dev@dpdk.org",
        "References": "<1535372574-18950-1-git-send-email-tdu@semihalf.com>\n\t<1537536294-16703-1-git-send-email-amo@semihalf.com>",
        "Subject": "[dpdk-dev] [PATCH v2 1/3] crypto/mvsam: add S/G support to crypto\n\tdirver",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id A95924CA6;\n\tFri, 21 Sep 2018 15:25:00 +0200 (CEST)",
            "from mail-lj1-f195.google.com (mail-lj1-f195.google.com\n\t[209.85.208.195]) by dpdk.org (Postfix) with ESMTP id 50FA24C96\n\tfor <dev@dpdk.org>; Fri, 21 Sep 2018 15:24:58 +0200 (CEST)",
            "by mail-lj1-f195.google.com with SMTP id l15-v6so11636000lji.6\n\tfor <dev@dpdk.org>; Fri, 21 Sep 2018 06:24:58 -0700 (PDT)",
            "from amok.semihalf.local (31-172-191-173.noc.fibertech.net.pl.\n\t[31.172.191.173]) by smtp.googlemail.com with ESMTPSA id\n\tv14-v6sm4868767lji.80.2018.09.21.06.24.56\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tFri, 21 Sep 2018 06:24:56 -0700 (PDT)"
        ],
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "X-Original-To": "patchwork@dpdk.org",
        "X-Mailer": "git-send-email 2.7.4",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=0IdQv9gF0c7CQbnJiOukcu5LfXJpigAZY/APRZFTTb0=;\n\tb=YGnjwc/N18vtA7DvlvKakBZtC9WAiueIbu0dPWaHwMLK8JZ1sw9wojak+s+vEUBmQb\n\tIoFkNhDQK6CXrgDqyXG+3GhBtSUCCom38vLzAlEERqjSY9F3RMbUxcpYT3Q9Lo2E6S6E\n\tb2ppF1CUefOc8x5oWvPpgMQKhquf7eTGOWmxinltWZ+igFfgxDKdRlq8njwRrYtQ7Pd8\n\tXUFw52gVHjm9fL7DM3f8sq97KR4qtpJUjTo3IEtA+5O5ZnHmzL7Ls9q6hMBHTRFf9fjz\n\tvYHsh7+7XnNG7pq83ebmpZTRxKdFVq02fUpkspUPH1yJdQSYmGsq1iJvd28HADhT/8zV\n\tRdgA==",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=semihalf-com.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=0IdQv9gF0c7CQbnJiOukcu5LfXJpigAZY/APRZFTTb0=;\n\tb=TqMe14xKjeR0qzdtQdrJMmM8EYe5uYvY1eUgaJHRB0QQoeXQKXmgWdoAOlhz22OwYm\n\tPN1Mrb3yN1GZUYNEig1xk2XHydkMR13bTVsPnwA9/LCVH1VtN1pRLlMdjx43D5fK2rWg\n\t8QQRjVgloamwk5SQiExa7XJYJ5XDLkg97jCfiC0NL3dAW7Swu2PpqiDiWjfQH4NCjmx/\n\tdCVL3t9FvIooXGFe4qsb8Dl94GZu1dvGJUcB0oF08bBOtroGrFtFp/kL8J7yxPf7NlT5\n\tOCDCOThAyMAIh8V1nQNIeRdmzatc+GUHQ41CSpZCjiZBjfpQ0/Hy6+E2nczFs1ppjGM0\n\tnq2Q==",
        "Date": "Fri, 21 Sep 2018 15:24:52 +0200",
        "X-Received": "by 2002:a2e:8188:: with SMTP id\n\te8-v6mr1846628ljg.138.1537536297607; \n\tFri, 21 Sep 2018 06:24:57 -0700 (PDT)",
        "To": "dev@dpdk.org",
        "From": "Andrzej Ostruszka <amo@semihalf.com>",
        "In-Reply-To": "<1537536294-16703-1-git-send-email-amo@semihalf.com>",
        "Cc": "mw@semihalf.com, nadavh@marvell.com, Zyta Szpak <zr@semihalf.com>,\n\tNatalie Samsonov <nsamsono@marvell.com>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Message-Id": "<1537536294-16703-2-git-send-email-amo@semihalf.com>",
        "Return-Path": "<dev-bounces@dpdk.org>"
    },
    "content": "From: Zyta Szpak <zr@semihalf.com>\n\nThe patch adds support for chained source mbufs given\nto crypto operations. The crypto engine accepts source buffer\ncontaining a number of segments. The destination buffer\nstays the same - always one segment.\nOn decryption, EIP engine will look for digest at 'auth_icv_offset'\noffset in SRC buffer.It must be placed in the last segment and the\noffset must be set to reach digest in the last segment.\nIf application doesn't placed digest in source mbuf, driver try to\ncopy it to a last segment.\n\nSigned-off-by: Zyta Szpak <zr@semihalf.com>\nSigned-off-by: Natalie Samsonov <nsamsono@marvell.com>\nReviewed-by: Dmitri Epshtein <dima@marvell.com>\n---\n drivers/crypto/mvsam/rte_mrvl_pmd.c         | 96 +++++++++++++++++++++--------\n drivers/crypto/mvsam/rte_mrvl_pmd_private.h |  7 +++\n 2 files changed, 76 insertions(+), 27 deletions(-)",
    "diff": "diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c\nindex 73eff75..977e478 100644\n--- a/drivers/crypto/mvsam/rte_mrvl_pmd.c\n+++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c\n@@ -437,8 +437,10 @@ mrvl_request_prepare(struct sam_cio_op_params *request,\n \t\tstruct rte_crypto_op *op)\n {\n \tstruct mrvl_crypto_session *sess;\n-\tstruct rte_mbuf *dst_mbuf;\n+\tstruct rte_mbuf *src_mbuf, *dst_mbuf;\n+\tuint16_t segments_nb;\n \tuint8_t *digest;\n+\tint i;\n \n \tif (unlikely(op->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) {\n \t\tMRVL_CRYPTO_LOG_ERR(\"MRVL CRYPTO PMD only supports session \"\n@@ -454,29 +456,47 @@ mrvl_request_prepare(struct sam_cio_op_params *request,\n \t\treturn -EINVAL;\n \t}\n \n-\t/*\n+\trequest->sa = sess->sam_sess;\n+\trequest->cookie = op;\n+\n+\tsrc_mbuf = op->sym->m_src;\n+\tsegments_nb = src_mbuf->nb_segs;\n+\t/* The following conditions must be met:\n+\t * - Destination buffer is required when segmented source buffer\n+\t * - Segmented destination buffer is not supported\n+\t */\n+\tif ((segments_nb > 1) && (!op->sym->m_dst)) {\n+\t\tMRVL_CRYPTO_LOG_ERR(\"op->sym->m_dst = NULL!\\n\");\n+\t\treturn -1;\n+\t}\n+\t/* For non SG case:\n \t * If application delivered us null dst buffer, it means it expects\n \t * us to deliver the result in src buffer.\n \t */\n \tdst_mbuf = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src;\n \n-\trequest->sa = sess->sam_sess;\n-\trequest->cookie = op;\n-\n-\t/* Single buffers only, sorry. */\n-\trequest->num_bufs = 1;\n-\trequest->src = src_bd;\n-\tsrc_bd->vaddr = rte_pktmbuf_mtod(op->sym->m_src, void *);\n-\tsrc_bd->paddr = rte_pktmbuf_iova(op->sym->m_src);\n-\tsrc_bd->len = rte_pktmbuf_data_len(op->sym->m_src);\n-\n-\t/* Empty source. */\n-\tif (rte_pktmbuf_data_len(op->sym->m_src) == 0) {\n-\t\t/* EIP does not support 0 length buffers. */\n-\t\tMRVL_CRYPTO_LOG_ERR(\"Buffer length == 0 not supported!\");\n+\tif (!rte_pktmbuf_is_contiguous(dst_mbuf)) {\n+\t\tMRVL_CRYPTO_LOG_ERR(\"Segmented destination buffer \"\n+\t\t\t\t    \"not supported.\\n\");\n \t\treturn -1;\n \t}\n \n+\trequest->num_bufs = segments_nb;\n+\tfor (i = 0; i < segments_nb; i++) {\n+\t\t/* Empty source. */\n+\t\tif (rte_pktmbuf_data_len(src_mbuf) == 0) {\n+\t\t\t/* EIP does not support 0 length buffers. */\n+\t\t\tMRVL_CRYPTO_LOG_ERR(\"Buffer length == 0 not supported!\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\tsrc_bd[i].vaddr = rte_pktmbuf_mtod(src_mbuf, void *);\n+\t\tsrc_bd[i].paddr = rte_pktmbuf_iova(src_mbuf);\n+\t\tsrc_bd[i].len = rte_pktmbuf_data_len(src_mbuf);\n+\n+\t\tsrc_mbuf = src_mbuf->next;\n+\t}\n+\trequest->src = src_bd;\n+\n \t/* Empty destination. */\n \tif (rte_pktmbuf_data_len(dst_mbuf) == 0) {\n \t\t/* Make dst buffer fit at least source data. */\n@@ -527,7 +547,7 @@ mrvl_request_prepare(struct sam_cio_op_params *request,\n \n \t/*\n \t * EIP supports only scenarios where ICV(digest buffer) is placed at\n-\t * auth_icv_offset. Any other placement means risking errors.\n+\t * auth_icv_offset.\n \t */\n \tif (sess->sam_sess_params.dir == SAM_DIR_ENCRYPT) {\n \t\t/*\n@@ -536,17 +556,36 @@ mrvl_request_prepare(struct sam_cio_op_params *request,\n \t\t */\n \t\tif (rte_pktmbuf_mtod_offset(\n \t\t\t\tdst_mbuf, uint8_t *,\n-\t\t\t\trequest->auth_icv_offset) == digest) {\n+\t\t\t\trequest->auth_icv_offset) == digest)\n \t\t\treturn 0;\n-\t\t}\n \t} else {/* sess->sam_sess_params.dir == SAM_DIR_DECRYPT */\n \t\t/*\n \t\t * EIP will look for digest at auth_icv_offset\n-\t\t * offset in SRC buffer.\n+\t\t * offset in SRC buffer. It must be placed in the last\n+\t\t * segment and the offset must be set to reach digest\n+\t\t * in the last segment\n \t\t */\n-\t\tif (rte_pktmbuf_mtod_offset(\n-\t\t\t\top->sym->m_src, uint8_t *,\n-\t\t\t\trequest->auth_icv_offset) == digest) {\n+\t\tstruct rte_mbuf *last_seg =  op->sym->m_src;\n+\t\tuint32_t d_offset = request->auth_icv_offset;\n+\t\tu32 d_size = sess->sam_sess_params.u.basic.auth_icv_len;\n+\t\tunsigned char *d_ptr;\n+\n+\t\t/* Find the last segment and the offset for the last segment */\n+\t\twhile ((last_seg->next != NULL) &&\n+\t\t\t\t(d_offset >= last_seg->data_len)) {\n+\t\t\td_offset -= last_seg->data_len;\n+\t\t\tlast_seg = last_seg->next;\n+\t\t}\n+\n+\t\tif (rte_pktmbuf_mtod_offset(last_seg, uint8_t *,\n+\t\t\t\t\t    d_offset) == digest)\n+\t\t\treturn 0;\n+\n+\t\t/* copy digest to last segment */\n+\t\tif (last_seg->buf_len >= (d_size + d_offset)) {\n+\t\t\td_ptr = (unsigned char *)last_seg->buf_addr +\n+\t\t\t\t d_offset;\n+\t\t\trte_memcpy(d_ptr, digest, d_size);\n \t\t\treturn 0;\n \t\t}\n \t}\n@@ -582,11 +621,10 @@ mrvl_crypto_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,\n \tint ret;\n \tstruct sam_cio_op_params requests[nb_ops];\n \t/*\n-\t * DPDK uses single fragment buffers, so we can KISS descriptors.\n \t * SAM does not store bd pointers, so on-stack scope will be enough.\n \t */\n-\tstruct sam_buf_info src_bd[nb_ops];\n-\tstruct sam_buf_info dst_bd[nb_ops];\n+\tstruct mrvl_crypto_src_table src_bd[nb_ops];\n+\tstruct sam_buf_info          dst_bd[nb_ops];\n \tstruct mrvl_crypto_qp *qp = (struct mrvl_crypto_qp *)queue_pair;\n \n \tif (nb_ops == 0)\n@@ -594,11 +632,14 @@ mrvl_crypto_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,\n \n \t/* Prepare the burst. */\n \tmemset(&requests, 0, sizeof(requests));\n+\tmemset(&src_bd, 0, sizeof(src_bd));\n \n \t/* Iterate through */\n \tfor (; iter_ops < nb_ops; ++iter_ops) {\n+\t\t/* store the op id for debug */\n+\t\tsrc_bd[iter_ops].iter_ops = iter_ops;\n \t\tif (mrvl_request_prepare(&requests[iter_ops],\n-\t\t\t\t\t&src_bd[iter_ops],\n+\t\t\t\t\tsrc_bd[iter_ops].src_bd,\n \t\t\t\t\t&dst_bd[iter_ops],\n \t\t\t\t\tops[iter_ops]) < 0) {\n \t\t\tMRVL_CRYPTO_LOG_ERR(\n@@ -752,6 +793,7 @@ cryptodev_mrvl_crypto_create(const char *name,\n \n \tsam_params.max_num_sessions = internals->max_nb_sessions;\n \n+\t/* sam_set_debug_flags(3); */\n \treturn sam_init(&sam_params);\n \n init_error:\ndiff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_private.h b/drivers/crypto/mvsam/rte_mrvl_pmd_private.h\nindex c16d95b..0689fc3 100644\n--- a/drivers/crypto/mvsam/rte_mrvl_pmd_private.h\n+++ b/drivers/crypto/mvsam/rte_mrvl_pmd_private.h\n@@ -38,6 +38,8 @@\n  */\n #define BITS2BYTES(x) ((x) >> 3)\n \n+#define MRVL_MAX_SEGMENTS 16\n+\n /** The operation order mode enumerator. */\n enum mrvl_crypto_chain_order {\n \tMRVL_CRYPTO_CHAIN_CIPHER_ONLY,\n@@ -84,6 +86,11 @@ struct mrvl_crypto_session {\n \tuint16_t cipher_iv_offset;\n } __rte_cache_aligned;\n \n+struct mrvl_crypto_src_table {\n+\tuint16_t iter_ops;\n+\tstruct sam_buf_info src_bd[MRVL_MAX_SEGMENTS];\n+} __rte_cache_aligned;\n+\n /** Set and validate MRVL crypto session parameters */\n extern int\n mrvl_crypto_set_session_parameters(struct mrvl_crypto_session *sess,\n",
    "prefixes": [
        "v2",
        "1/3"
    ]
}