Show a patch.

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

{
    "id": 74471,
    "url": "https://patches.dpdk.org/api/patches/74471/",
    "web_url": "https://patches.dpdk.org/patch/74471/",
    "project": {
        "id": 1,
        "url": "https://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": "<1595226378-81144-12-git-send-email-orika@mellanox.com>",
    "date": "2020-07-20T06:26:15",
    "name": "[v6,11/13] regex/mlx5: add enqueue implementation",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "00c0ba396960c6b301d153a10734d35f66d901b9",
    "submitter": {
        "id": 795,
        "url": "https://patches.dpdk.org/api/people/795/",
        "name": "Ori Kam",
        "email": "orika@mellanox.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/patch/74471/mbox/",
    "series": [
        {
            "id": 11159,
            "url": "https://patches.dpdk.org/api/series/11159/",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=11159",
            "date": "2020-07-20T06:26:04",
            "name": "add Mellanox RegEx PMD",
            "version": 6,
            "mbox": "https://patches.dpdk.org/series/11159/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/74471/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/74471/checks/",
    "tags": {},
    "headers": {
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "List-Post": "<mailto:dev@dpdk.org>",
        "References": "<1593941027-86651-1-git-send-email-orika@mellanox.com>\n <1595226378-81144-1-git-send-email-orika@mellanox.com>",
        "X-BeenThere": "dev@dpdk.org",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "Subject": "[dpdk-dev] [PATCH v6 11/13] regex/mlx5: add enqueue implementation",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "From": "Ori Kam <orika@mellanox.com>",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 20B32A0540;\n\tMon, 20 Jul 2020 08:28:43 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 42C9F1BFB2;\n\tMon, 20 Jul 2020 08:27:11 +0200 (CEST)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by dpdk.org (Postfix) with ESMTP id 6EC3B1BED3\n for <dev@dpdk.org>; Mon, 20 Jul 2020 08:27:02 +0200 (CEST)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n orika@mellanox.com) with SMTP; 20 Jul 2020 09:27:00 +0300",
            "from pegasus04.mtr.labs.mlnx. (pegasus04.mtr.labs.mlnx\n [10.210.16.126])\n by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 06K6QKun008177;\n Mon, 20 Jul 2020 09:27:00 +0300"
        ],
        "To": "jerinj@marvell.com, xiang.w.wang@intel.com, matan@mellanox.com,\n viacheslavo@mellanox.com",
        "X-Mailer": "git-send-email 1.8.3.1",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "Date": "Mon, 20 Jul 2020 06:26:15 +0000",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "In-Reply-To": "<1595226378-81144-1-git-send-email-orika@mellanox.com>",
        "Cc": "guyk@marvell.com, dev@dpdk.org, pbhagavatula@marvell.com,\n shahafs@mellanox.com, hemant.agrawal@nxp.com, opher@mellanox.com,\n alexr@mellanox.com, dovrat@marvell.com, pkapoor@marvell.com,\n nipun.gupta@nxp.com, bruce.richardson@intel.com, yang.a.hong@intel.com,\n harry.chang@intel.com, gu.jian1@zte.com.cn, shanjiangh@chinatelecom.cn,\n zhangy.yun@chinatelecom.cn, lixingfu@huachentel.com,\n wushuai@inspur.com, yuyingxia@yxlink.com, fanchenggang@sunyainfo.com,\n davidfgao@tencent.com, liuzhong1@chinaunicom.cn, zhaoyong11@huawei.com,\n oc@yunify.com, jim@netgate.com, hongjun.ni@intel.com, deri@ntop.org,\n fc@napatech.com, arthur.su@lionic.com, thomas@monjalon.net,\n orika@mellanox.com, rasland@mellanox.com,\n Yuval Avnery <yuvalav@mellanox.com>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Message-Id": "<1595226378-81144-12-git-send-email-orika@mellanox.com>",
        "Return-Path": "<dev-bounces@dpdk.org>"
    },
    "content": "From: Yuval Avnery <yuvalav@mellanox.com>\n\nWill look for a free SQ to send the job on.\ndoorbell will be given when sq is full, or no more jobs on the burst.\n\nSigned-off-by: Yuval Avnery <yuvalav@mellanox.com>\nAcked-by: Ori Kam <orika@mellanox.com>\n\n---\n drivers/regex/mlx5/mlx5_regex.c          |   1 +\n drivers/regex/mlx5/mlx5_regex.h          |   6 ++\n drivers/regex/mlx5/mlx5_regex_control.c  |   2 +\n drivers/regex/mlx5/mlx5_regex_fastpath.c | 122 ++++++++++++++++++++++++++++++-\n 4 files changed, 129 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c\nindex 309fde8..607ca4d 100644\n--- a/drivers/regex/mlx5/mlx5_regex.c\n+++ b/drivers/regex/mlx5/mlx5_regex.c\n@@ -167,6 +167,7 @@\n \t\tgoto error;\n \t}\n \tpriv->regexdev->dev_ops = &mlx5_regexdev_ops;\n+\tpriv->regexdev->enqueue = mlx5_regexdev_enqueue;\n \tpriv->regexdev->device = (struct rte_device *)pci_dev;\n \tpriv->regexdev->data->dev_private = priv;\n \tpriv->regexdev->state = RTE_REGEXDEV_READY;\ndiff --git a/drivers/regex/mlx5/mlx5_regex.h b/drivers/regex/mlx5/mlx5_regex.h\nindex 21bb02b..fb81cb8 100644\n--- a/drivers/regex/mlx5/mlx5_regex.h\n+++ b/drivers/regex/mlx5/mlx5_regex.h\n@@ -21,6 +21,9 @@ struct mlx5_regex_sq {\n \tuint32_t dbr_umem; /* Door bell record umem id. */\n \tuint8_t *wqe; /* The SQ ring buffer. */\n \tstruct mlx5dv_devx_umem *wqe_umem; /* SQ buffer umem. */\n+\tsize_t pi, db_pi;\n+\tsize_t ci;\n+\tuint32_t sqn;\n \tuint32_t *dbr;\n };\n \n@@ -45,6 +48,7 @@ struct mlx5_regex_qp {\n \tstruct ibv_mr *metadata;\n \tstruct ibv_mr *inputs;\n \tstruct ibv_mr *outputs;\n+\tsize_t ci, pi;\n };\n \n struct mlx5_regex_db {\n@@ -99,4 +103,6 @@ int mlx5_regex_qp_setup(struct rte_regexdev *dev, uint16_t qp_ind,\n \n /* mlx5_regex_fastpath.c */\n int mlx5_regexdev_setup_fastpath(struct mlx5_regex_priv *priv, uint32_t qp_id);\n+uint16_t mlx5_regexdev_enqueue(struct rte_regexdev *dev, uint16_t qp_id,\n+\t\t       struct rte_regex_ops **ops, uint16_t nb_ops);\n #endif /* MLX5_REGEX_H */\ndiff --git a/drivers/regex/mlx5/mlx5_regex_control.c b/drivers/regex/mlx5/mlx5_regex_control.c\nindex ec57e24..f144c69 100644\n--- a/drivers/regex/mlx5/mlx5_regex_control.c\n+++ b/drivers/regex/mlx5/mlx5_regex_control.c\n@@ -219,6 +219,8 @@\n \tsq->wqe = buf;\n \tsq->wqe_umem = mlx5_glue->devx_umem_reg(priv->ctx, buf, 64 * sq_size,\n \t\t\t\t\t\t7);\n+\tsq->ci = 0;\n+\tsq->pi = 0;\n \tif (!sq->wqe_umem) {\n \t\tDRV_LOG(ERR, \"Can't register wqe mem.\");\n \t\trte_errno  = ENOMEM;\ndiff --git a/drivers/regex/mlx5/mlx5_regex_fastpath.c b/drivers/regex/mlx5/mlx5_regex_fastpath.c\nindex 8d55bbc..ff6386b 100644\n--- a/drivers/regex/mlx5/mlx5_regex_fastpath.c\n+++ b/drivers/regex/mlx5/mlx5_regex_fastpath.c\n@@ -27,10 +27,14 @@\n /* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */\n #include <infiniband/mlx5dv.h>\n \n-#define MAX_WQE_INDEX 0xffff\n+#define MLX5_REGEX_MAX_WQE_INDEX 0xffff\n #define MLX5_REGEX_METADATA_SIZE 64\n #define MLX5_REGEX_MAX_INPUT (1 << 14)\n #define MLX5_REGEX_MAX_OUTPUT (1 << 11)\n+#define MLX5_REGEX_WQE_CTRL_OFFSET 12\n+#define MLX5_REGEX_WQE_METADATA_OFFSET 16\n+#define MLX5_REGEX_WQE_GATHER_OFFSET 32\n+#define MLX5_REGEX_WQE_SCATTER_OFFSET 48\n \n #define MLX5_REGEX_WQE_METADATA_OFFSET 16\n #define MLX5_REGEX_WQE_GATHER_OFFSET 32\n@@ -74,6 +78,120 @@ struct mlx5_regex_job {\n \tseg->addr = rte_cpu_to_be_64(address);\n }\n \n+static inline void\n+set_regex_ctrl_seg(void *seg, uint8_t le, uint16_t subset_id0,\n+\t\t   uint16_t subset_id1, uint16_t subset_id2,\n+\t\t   uint16_t subset_id3, uint8_t ctrl)\n+{\n+\tMLX5_SET(regexp_mmo_control, seg, le, le);\n+\tMLX5_SET(regexp_mmo_control, seg, ctrl, ctrl);\n+\tMLX5_SET(regexp_mmo_control, seg, subset_id_0, subset_id0);\n+\tMLX5_SET(regexp_mmo_control, seg, subset_id_1, subset_id1);\n+\tMLX5_SET(regexp_mmo_control, seg, subset_id_2, subset_id2);\n+\tMLX5_SET(regexp_mmo_control, seg, subset_id_3, subset_id3);\n+}\n+\n+static inline void\n+set_wqe_ctrl_seg(struct mlx5_wqe_ctrl_seg *seg, uint16_t pi, uint8_t opcode,\n+\t\t uint8_t opmod, uint32_t qp_num, uint8_t fm_ce_se, uint8_t ds,\n+\t\t uint8_t signature, uint32_t imm)\n+{\n+\tseg->opmod_idx_opcode = rte_cpu_to_be_32(((uint32_t)opmod << 24) |\n+\t\t\t\t\t\t ((uint32_t)pi << 8) |\n+\t\t\t\t\t\t opcode);\n+\tseg->qpn_ds = rte_cpu_to_be_32((qp_num << 8) | ds);\n+\tseg->fm_ce_se = fm_ce_se;\n+\tseg->signature = signature;\n+\tseg->imm = imm;\n+}\n+\n+static inline void\n+prep_one(struct mlx5_regex_sq *sq, struct rte_regex_ops *op,\n+\t struct mlx5_regex_job *job)\n+{\n+\tsize_t wqe_offset = (sq->pi & (sq_size_get(sq) - 1)) * MLX5_SEND_WQE_BB;\n+\tuint8_t *wqe = (uint8_t *)sq->wqe + wqe_offset;\n+\tint ds = 4; /*  ctrl + meta + input + output */\n+\n+\tmemcpy(job->input,\n+\t\trte_pktmbuf_mtod(op->mbuf, void *),\n+\t\trte_pktmbuf_data_len(op->mbuf));\n+\tset_wqe_ctrl_seg((struct mlx5_wqe_ctrl_seg *)wqe, sq->pi,\n+\t\t\t MLX5_OPCODE_MMO, MLX5_OPC_MOD_MMO_REGEX, sq->obj->id,\n+\t\t\t 0, ds, 0, 0);\n+\tset_regex_ctrl_seg(wqe + 12, 0, op->group_id0, op->group_id1,\n+\t\t\t   op->group_id2,\n+\t\t\t   op->group_id3, 0);\n+\tstruct mlx5_wqe_data_seg *input_seg =\n+\t\t(struct mlx5_wqe_data_seg *)(wqe +\n+\t\t\t\t\t     MLX5_REGEX_WQE_GATHER_OFFSET);\n+\tinput_seg->byte_count =\n+\t\trte_cpu_to_be_32(rte_pktmbuf_data_len(op->mbuf));\n+\tjob->user_id = op->user_id;\n+\tsq->db_pi = sq->pi;\n+\tsq->pi = (sq->pi + 1) & MLX5_REGEX_MAX_WQE_INDEX;\n+}\n+\n+static inline void\n+send_doorbell(struct mlx5dv_devx_uar *uar, struct mlx5_regex_sq *sq)\n+{\n+\tsize_t wqe_offset = (sq->db_pi & (sq_size_get(sq) - 1)) *\n+\t\tMLX5_SEND_WQE_BB;\n+\tuint8_t *wqe = (uint8_t *)sq->wqe + wqe_offset;\n+\t((struct mlx5_wqe_ctrl_seg *)wqe)->fm_ce_se = MLX5_WQE_CTRL_CQ_UPDATE;\n+\tuint64_t *doorbell_addr =\n+\t\t(uint64_t *)((uint8_t *)uar->base_addr + 0x800);\n+\trte_cio_wmb();\n+\tsq->dbr[MLX5_SND_DBR] = rte_cpu_to_be_32((sq->db_pi + 1) &\n+\t\t\t\t\t\t MLX5_REGEX_MAX_WQE_INDEX);\n+\trte_wmb();\n+\t*doorbell_addr = *(volatile uint64_t *)wqe;\n+\trte_wmb();\n+}\n+\n+static inline int\n+can_send(struct mlx5_regex_sq *sq) {\n+\treturn unlikely(sq->ci > sq->pi) ?\n+\t\t\tMLX5_REGEX_MAX_WQE_INDEX + sq->pi - sq->ci <\n+\t\t\tsq_size_get(sq) :\n+\t\t\tsq->pi - sq->ci < sq_size_get(sq);\n+}\n+\n+static inline uint32_t\n+job_id_get(uint32_t qid, size_t sq_size, size_t index) {\n+\treturn qid*sq_size + index % sq_size;\n+}\n+\n+uint16_t\n+mlx5_regexdev_enqueue(struct rte_regexdev *dev, uint16_t qp_id,\n+\t\t      struct rte_regex_ops **ops, uint16_t nb_ops)\n+{\n+\tstruct mlx5_regex_priv *priv = dev->data->dev_private;\n+\tstruct mlx5_regex_qp *queue = &priv->qps[qp_id];\n+\tstruct mlx5_regex_sq *sq;\n+\tsize_t sqid, job_id, i = 0;\n+\n+\twhile ((sqid = ffs(queue->free_sqs))) {\n+\t\tsqid--; /* ffs returns 1 for bit 0 */\n+\t\tsq = &queue->sqs[sqid];\n+\t\twhile (can_send(sq)) {\n+\t\t\tjob_id = job_id_get(sqid, sq_size_get(sq), sq->pi);\n+\t\t\tprep_one(sq, ops[i], &queue->jobs[job_id]);\n+\t\t\ti++;\n+\t\t\tif (unlikely(i == nb_ops)) {\n+\t\t\t\tsend_doorbell(priv->uar, sq);\n+\t\t\t\tgoto out;\n+\t\t\t}\n+\t\t}\n+\t\tqueue->free_sqs &= ~(1 << sqid);\n+\t\tsend_doorbell(priv->uar, sq);\n+\t}\n+\n+out:\n+\tqueue->pi += i;\n+\treturn i;\n+}\n+\n static void\n setup_sqs(struct mlx5_regex_qp *queue)\n {\n@@ -149,7 +267,7 @@ struct mlx5_regex_job {\n \t\tgoto err_output;\n \t}\n \tqp->outputs = mlx5_glue->reg_mr(pd, ptr,\n-\t\t\t\t\tMLX5_REGEX_MAX_OUTPUT*qp->nb_desc,\n+\t\t\t\t\tMLX5_REGEX_MAX_OUTPUT * qp->nb_desc,\n \t\t\t\t\tIBV_ACCESS_LOCAL_WRITE);\n \tif (!qp->outputs) {\n \t\trte_free(ptr);\n",
    "prefixes": [
        "v6",
        "11/13"
    ]
}