get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 48915,
    "url": "http://patchwork.dpdk.org/api/patches/48915/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1544805623-18150-4-git-send-email-konstantin.ananyev@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/?format=api",
        "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",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1544805623-18150-4-git-send-email-konstantin.ananyev@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1544805623-18150-4-git-send-email-konstantin.ananyev@intel.com",
    "date": "2018-12-14T16:40:17",
    "name": "[v4,3/9] examples/ipsec-secgw: fix crypto-op might never get dequeued",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "a50852529e052dffa87f2b5861802a68b9204b20",
    "submitter": {
        "id": 33,
        "url": "http://patchwork.dpdk.org/api/people/33/?format=api",
        "name": "Ananyev, Konstantin",
        "email": "konstantin.ananyev@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1544805623-18150-4-git-send-email-konstantin.ananyev@intel.com/mbox/",
    "series": [
        {
            "id": 2795,
            "url": "http://patchwork.dpdk.org/api/series/2795/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=2795",
            "date": "2018-12-14T16:40:17",
            "name": null,
            "version": 4,
            "mbox": "http://patchwork.dpdk.org/series/2795/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/48915/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/48915/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@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 8A9E61B7D5;\n\tFri, 14 Dec 2018 17:40:38 +0100 (CET)",
            "from mga06.intel.com (mga06.intel.com [134.134.136.31])\n\tby dpdk.org (Postfix) with ESMTP id 2B6131B5D7\n\tfor <dev@dpdk.org>; Fri, 14 Dec 2018 17:40:33 +0100 (CET)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n\tby orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t14 Dec 2018 08:40:32 -0800",
            "from sivswdev08.ir.intel.com (HELO localhost.localdomain)\n\t([10.237.217.47])\n\tby orsmga008.jf.intel.com with ESMTP; 14 Dec 2018 08:40:31 -0800"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.56,353,1539673200\"; d=\"scan'208\";a=\"101573807\"",
        "From": "Konstantin Ananyev <konstantin.ananyev@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "akhil.goyal@nxp.com, radu.nicolau@intel.com,\n\tKonstantin Ananyev <konstantin.ananyev@intel.com>",
        "Date": "Fri, 14 Dec 2018 16:40:17 +0000",
        "Message-Id": "<1544805623-18150-4-git-send-email-konstantin.ananyev@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": "<1544111691-7481-1-git-send-email-konstantin.ananyev@intel.com>",
        "References": "<1544111691-7481-1-git-send-email-konstantin.ananyev@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v4 3/9] examples/ipsec-secgw: fix crypto-op might\n\tnever get dequeued",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "In some cases crypto-ops could never be dequeued from the crypto-device.\nThe easiest way to reproduce:\nstart ipsec-secgw with crypto-dev and send to it less then 32 packets.\nnone packets will be forwarded.\nReason for that is that the application does dequeue() from crypto-queues\nonly when new packets arrive.\nThis patch makes sure it calls dequeue() on a regular basis.\n\nFixes: c64278c0c18b (\"examples/ipsec-secgw: rework processing loop\")\n\nSigned-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>\nAcked-by: Radu Nicolau <radu.nicolau@intel.com>\n---\n examples/ipsec-secgw/ipsec-secgw.c | 136 ++++++++++++++++++++++++-----\n examples/ipsec-secgw/ipsec.c       |  60 ++++++++-----\n examples/ipsec-secgw/ipsec.h       |  11 +++\n 3 files changed, 165 insertions(+), 42 deletions(-)",
    "diff": "diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c\nindex 2ed757922..62443172a 100644\n--- a/examples/ipsec-secgw/ipsec-secgw.c\n+++ b/examples/ipsec-secgw/ipsec-secgw.c\n@@ -456,38 +456,55 @@ inbound_sp_sa(struct sp_ctx *sp, struct sa_ctx *sa, struct traffic_type *ip,\n \tip->num = j;\n }\n \n-static inline void\n-process_pkts_inbound(struct ipsec_ctx *ipsec_ctx,\n-\t\tstruct ipsec_traffic *traffic)\n+static void\n+split46_traffic(struct ipsec_traffic *trf, struct rte_mbuf *mb[], uint32_t num)\n {\n+\tuint32_t i, n4, n6;\n+\tstruct ip *ip;\n \tstruct rte_mbuf *m;\n-\tuint16_t idx, nb_pkts_in, i, n_ip4, n_ip6;\n \n-\tnb_pkts_in = ipsec_inbound(ipsec_ctx, traffic->ipsec.pkts,\n-\t\t\ttraffic->ipsec.num, MAX_PKT_BURST);\n+\tn4 = trf->ip4.num;\n+\tn6 = trf->ip6.num;\n \n-\tn_ip4 = traffic->ip4.num;\n-\tn_ip6 = traffic->ip6.num;\n+\tfor (i = 0; i < num; i++) {\n+\n+\t\tm = mb[i];\n+\t\tip = rte_pktmbuf_mtod(m, struct ip *);\n \n-\t/* SP/ACL Inbound check ipsec and ip4 */\n-\tfor (i = 0; i < nb_pkts_in; i++) {\n-\t\tm = traffic->ipsec.pkts[i];\n-\t\tstruct ip *ip = rte_pktmbuf_mtod(m, struct ip *);\n \t\tif (ip->ip_v == IPVERSION) {\n-\t\t\tidx = traffic->ip4.num++;\n-\t\t\ttraffic->ip4.pkts[idx] = m;\n-\t\t\ttraffic->ip4.data[idx] = rte_pktmbuf_mtod_offset(m,\n+\t\t\ttrf->ip4.pkts[n4] = m;\n+\t\t\ttrf->ip4.data[n4] = rte_pktmbuf_mtod_offset(m,\n \t\t\t\t\tuint8_t *, offsetof(struct ip, ip_p));\n+\t\t\tn4++;\n \t\t} else if (ip->ip_v == IP6_VERSION) {\n-\t\t\tidx = traffic->ip6.num++;\n-\t\t\ttraffic->ip6.pkts[idx] = m;\n-\t\t\ttraffic->ip6.data[idx] = rte_pktmbuf_mtod_offset(m,\n+\t\t\ttrf->ip6.pkts[n6] = m;\n+\t\t\ttrf->ip6.data[n6] = rte_pktmbuf_mtod_offset(m,\n \t\t\t\t\tuint8_t *,\n \t\t\t\t\toffsetof(struct ip6_hdr, ip6_nxt));\n+\t\t\tn6++;\n \t\t} else\n \t\t\trte_pktmbuf_free(m);\n \t}\n \n+\ttrf->ip4.num = n4;\n+\ttrf->ip6.num = n6;\n+}\n+\n+\n+static inline void\n+process_pkts_inbound(struct ipsec_ctx *ipsec_ctx,\n+\t\tstruct ipsec_traffic *traffic)\n+{\n+\tuint16_t nb_pkts_in, n_ip4, n_ip6;\n+\n+\tn_ip4 = traffic->ip4.num;\n+\tn_ip6 = traffic->ip6.num;\n+\n+\tnb_pkts_in = ipsec_inbound(ipsec_ctx, traffic->ipsec.pkts,\n+\t\t\ttraffic->ipsec.num, MAX_PKT_BURST);\n+\n+\tsplit46_traffic(traffic, traffic->ipsec.pkts, nb_pkts_in);\n+\n \tinbound_sp_sa(ipsec_ctx->sp4_ctx, ipsec_ctx->sa_ctx, &traffic->ip4,\n \t\t\tn_ip4);\n \n@@ -782,7 +799,7 @@ process_pkts(struct lcore_conf *qconf, struct rte_mbuf **pkts,\n }\n \n static inline void\n-drain_buffers(struct lcore_conf *qconf)\n+drain_tx_buffers(struct lcore_conf *qconf)\n {\n \tstruct buffer *buf;\n \tuint32_t portid;\n@@ -796,6 +813,81 @@ drain_buffers(struct lcore_conf *qconf)\n \t}\n }\n \n+static inline void\n+drain_crypto_buffers(struct lcore_conf *qconf)\n+{\n+\tuint32_t i;\n+\tstruct ipsec_ctx *ctx;\n+\n+\t/* drain inbound buffers*/\n+\tctx = &qconf->inbound;\n+\tfor (i = 0; i != ctx->nb_qps; i++) {\n+\t\tif (ctx->tbl[i].len != 0)\n+\t\t\tenqueue_cop_burst(ctx->tbl  + i);\n+\t}\n+\n+\t/* drain outbound buffers*/\n+\tctx = &qconf->outbound;\n+\tfor (i = 0; i != ctx->nb_qps; i++) {\n+\t\tif (ctx->tbl[i].len != 0)\n+\t\t\tenqueue_cop_burst(ctx->tbl  + i);\n+\t}\n+}\n+\n+static void\n+drain_inbound_crypto_queues(const struct lcore_conf *qconf,\n+\t\tstruct ipsec_ctx *ctx)\n+{\n+\tuint32_t n;\n+\tstruct ipsec_traffic trf;\n+\n+\t/* dequeue packets from crypto-queue */\n+\tn = ipsec_inbound_cqp_dequeue(ctx, trf.ipsec.pkts,\n+\t\t\tRTE_DIM(trf.ipsec.pkts));\n+\tif (n == 0)\n+\t\treturn;\n+\n+\ttrf.ip4.num = 0;\n+\ttrf.ip6.num = 0;\n+\n+\t/* split traffic by ipv4-ipv6 */\n+\tsplit46_traffic(&trf, trf.ipsec.pkts, n);\n+\n+\t/* process ipv4 packets */\n+\tinbound_sp_sa(ctx->sp4_ctx, ctx->sa_ctx, &trf.ip4, 0);\n+\troute4_pkts(qconf->rt4_ctx, trf.ip4.pkts, trf.ip4.num);\n+\n+\t/* process ipv6 packets */\n+\tinbound_sp_sa(ctx->sp6_ctx, ctx->sa_ctx, &trf.ip6, 0);\n+\troute6_pkts(qconf->rt6_ctx, trf.ip6.pkts, trf.ip6.num);\n+}\n+\n+static void\n+drain_outbound_crypto_queues(const struct lcore_conf *qconf,\n+\t\tstruct ipsec_ctx *ctx)\n+{\n+\tuint32_t n;\n+\tstruct ipsec_traffic trf;\n+\n+\t/* dequeue packets from crypto-queue */\n+\tn = ipsec_outbound_cqp_dequeue(ctx, trf.ipsec.pkts,\n+\t\t\tRTE_DIM(trf.ipsec.pkts));\n+\tif (n == 0)\n+\t\treturn;\n+\n+\ttrf.ip4.num = 0;\n+\ttrf.ip6.num = 0;\n+\n+\t/* split traffic by ipv4-ipv6 */\n+\tsplit46_traffic(&trf, trf.ipsec.pkts, n);\n+\n+\t/* process ipv4 packets */\n+\troute4_pkts(qconf->rt4_ctx, trf.ip4.pkts, trf.ip4.num);\n+\n+\t/* process ipv6 packets */\n+\troute6_pkts(qconf->rt6_ctx, trf.ip6.pkts, trf.ip6.num);\n+}\n+\n /* main processing loop */\n static int32_t\n main_loop(__attribute__((unused)) void *dummy)\n@@ -853,7 +945,8 @@ main_loop(__attribute__((unused)) void *dummy)\n \t\tdiff_tsc = cur_tsc - prev_tsc;\n \n \t\tif (unlikely(diff_tsc > drain_tsc)) {\n-\t\t\tdrain_buffers(qconf);\n+\t\t\tdrain_tx_buffers(qconf);\n+\t\t\tdrain_crypto_buffers(qconf);\n \t\t\tprev_tsc = cur_tsc;\n \t\t}\n \n@@ -867,6 +960,9 @@ main_loop(__attribute__((unused)) void *dummy)\n \t\t\tif (nb_rx > 0)\n \t\t\t\tprocess_pkts(qconf, pkts, nb_rx, portid);\n \t\t}\n+\n+\t\tdrain_inbound_crypto_queues(qconf, &qconf->inbound);\n+\t\tdrain_outbound_crypto_queues(qconf, &qconf->outbound);\n \t}\n }\n \ndiff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c\nindex 3d415f1af..8bf928a23 100644\n--- a/examples/ipsec-secgw/ipsec.c\n+++ b/examples/ipsec-secgw/ipsec.c\n@@ -333,33 +333,35 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa)\n \treturn 0;\n }\n \n+/*\n+ * queue crypto-ops into PMD queue.\n+ */\n+void\n+enqueue_cop_burst(struct cdev_qp *cqp)\n+{\n+\tuint32_t i, len, ret;\n+\n+\tlen = cqp->len;\n+\tret = rte_cryptodev_enqueue_burst(cqp->id, cqp->qp, cqp->buf, len);\n+\tif (ret < len) {\n+\t\tRTE_LOG_DP(DEBUG, IPSEC, \"Cryptodev %u queue %u:\"\n+\t\t\t\" enqueued %u crypto ops out of %u\\n\",\n+\t\t\tcqp->id, cqp->qp, ret, len);\n+\t\t\t/* drop packets that we fail to enqueue */\n+\t\t\tfor (i = ret; i < len; i++)\n+\t\t\t\trte_pktmbuf_free(cqp->buf[i]->sym->m_src);\n+\t}\n+\tcqp->in_flight += ret;\n+\tcqp->len = 0;\n+}\n+\n static inline void\n enqueue_cop(struct cdev_qp *cqp, struct rte_crypto_op *cop)\n {\n-\tint32_t ret = 0, i;\n-\n \tcqp->buf[cqp->len++] = cop;\n \n-\tif (cqp->len == MAX_PKT_BURST) {\n-\t\tint enq_size = cqp->len;\n-\t\tif ((cqp->in_flight + enq_size) > MAX_INFLIGHT)\n-\t\t\tenq_size -=\n-\t\t\t    (int)((cqp->in_flight + enq_size) - MAX_INFLIGHT);\n-\n-\t\tif (enq_size > 0)\n-\t\t\tret = rte_cryptodev_enqueue_burst(cqp->id, cqp->qp,\n-\t\t\t\t\tcqp->buf, enq_size);\n-\t\tif (ret < cqp->len) {\n-\t\t\tRTE_LOG_DP(DEBUG, IPSEC, \"Cryptodev %u queue %u:\"\n-\t\t\t\t\t\" enqueued %u crypto ops out of %u\\n\",\n-\t\t\t\t\t cqp->id, cqp->qp,\n-\t\t\t\t\t ret, cqp->len);\n-\t\t\tfor (i = ret; i < cqp->len; i++)\n-\t\t\t\trte_pktmbuf_free(cqp->buf[i]->sym->m_src);\n-\t\t}\n-\t\tcqp->in_flight += ret;\n-\t\tcqp->len = 0;\n-\t}\n+\tif (cqp->len == MAX_PKT_BURST)\n+\t\tenqueue_cop_burst(cqp);\n }\n \n static inline void\n@@ -548,6 +550,13 @@ ipsec_inbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],\n \treturn ipsec_dequeue(esp_inbound_post, ctx, pkts, len);\n }\n \n+uint16_t\n+ipsec_inbound_cqp_dequeue(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],\n+\t\tuint16_t len)\n+{\n+\treturn ipsec_dequeue(esp_inbound_post, ctx, pkts, len);\n+}\n+\n uint16_t\n ipsec_outbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],\n \t\tuint32_t sa_idx[], uint16_t nb_pkts, uint16_t len)\n@@ -560,3 +569,10 @@ ipsec_outbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],\n \n \treturn ipsec_dequeue(esp_outbound_post, ctx, pkts, len);\n }\n+\n+uint16_t\n+ipsec_outbound_cqp_dequeue(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],\n+\t\tuint16_t len)\n+{\n+\treturn ipsec_dequeue(esp_outbound_post, ctx, pkts, len);\n+}\ndiff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h\nindex 580f7876b..2f04b7d68 100644\n--- a/examples/ipsec-secgw/ipsec.h\n+++ b/examples/ipsec-secgw/ipsec.h\n@@ -184,6 +184,14 @@ uint16_t\n ipsec_outbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],\n \t\tuint32_t sa_idx[], uint16_t nb_pkts, uint16_t len);\n \n+uint16_t\n+ipsec_inbound_cqp_dequeue(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],\n+\t\tuint16_t len);\n+\n+uint16_t\n+ipsec_outbound_cqp_dequeue(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],\n+\t\tuint16_t len);\n+\n static inline uint16_t\n ipsec_metadata_size(void)\n {\n@@ -248,4 +256,7 @@ sa_check_offloads(uint16_t port_id, uint64_t *rx_offloads,\n int\n add_dst_ethaddr(uint16_t port, const struct ether_addr *addr);\n \n+void\n+enqueue_cop_burst(struct cdev_qp *cqp);\n+\n #endif /* __IPSEC_H__ */\n",
    "prefixes": [
        "v4",
        "3/9"
    ]
}