Show a patch.

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

{
    "id": 74463,
    "url": "https://patches.dpdk.org/api/patches/74463/",
    "web_url": "https://patches.dpdk.org/patch/74463/",
    "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-4-git-send-email-orika@mellanox.com>",
    "date": "2020-07-20T06:26:07",
    "name": "[v6,03/13] regex/mlx5: add probe function",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "40c4cf41774eb33eb3c4bfb102e1ef4a9570ee07",
    "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/74463/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/74463/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/74463/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 03/13] regex/mlx5: add probe function",
        "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 08004A0540;\n\tMon, 20 Jul 2020 08:27:03 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id BBB0E2D13;\n\tMon, 20 Jul 2020 08:26:36 +0200 (CEST)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by dpdk.org (Postfix) with ESMTP id 3A0D72C5E\n for <dev@dpdk.org>; Mon, 20 Jul 2020 08:26:33 +0200 (CEST)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n orika@mellanox.com) with SMTP; 20 Jul 2020 09:26:32 +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 06K6QKuf008177;\n Mon, 20 Jul 2020 09:26:31 +0300"
        ],
        "To": "jerinj@marvell.com, xiang.w.wang@intel.com, matan@mellanox.com,\n viacheslavo@mellanox.com, Shahaf Shuler <shahafs@mellanox.com>,\n Thomas Monjalon <thomas@monjalon.net>",
        "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:07 +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 hemant.agrawal@nxp.com, opher@mellanox.com, alexr@mellanox.com,\n dovrat@marvell.com, pkapoor@marvell.com, nipun.gupta@nxp.com,\n 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, orika@mellanox.com,\n rasland@mellanox.com, Parav Pandit <parav@mellanox.com>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Message-Id": "<1595226378-81144-4-git-send-email-orika@mellanox.com>",
        "Return-Path": "<dev-bounces@dpdk.org>"
    },
    "content": "This commit adds the probe function to the RegEx PMD.\n\nSigned-off-by: Parav Pandit <parav@mellanox.com>\nSigned-off-by: Ori Kam <orika@mellanox.com>\n---\n drivers/common/mlx5/mlx5_devx_cmds.c |   3 +\n drivers/common/mlx5/mlx5_devx_cmds.h |   2 +\n drivers/common/mlx5/mlx5_prm.h       |   9 +-\n drivers/regex/mlx5/Makefile          |   2 +\n drivers/regex/mlx5/mlx5_regex.c      | 172 +++++++++++++++++++++++++++++++++++\n drivers/regex/mlx5/mlx5_regex.h      |   6 ++\n mk/rte.app.mk                        |   1 +\n 7 files changed, 193 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c\nindex 757c55e..66b8d24 100644\n--- a/drivers/common/mlx5/mlx5_devx_cmds.c\n+++ b/drivers/common/mlx5/mlx5_devx_cmds.c\n@@ -706,6 +706,9 @@ struct mlx5_devx_obj *\n \t\t\t\t      device_frequency_khz);\n \tattr->scatter_fcs_w_decap_disable =\n \t\tMLX5_GET(cmd_hca_cap, hcattr, scatter_fcs_w_decap_disable);\n+\tattr->regex = MLX5_GET(cmd_hca_cap, hcattr, regexp);\n+\tattr->regexp_num_of_engines = MLX5_GET(cmd_hca_cap, hcattr,\n+\t\t\t\t\t       regexp_num_of_engines);\n \tif (attr->qos.sup) {\n \t\tMLX5_SET(query_hca_cap_in, in, op_mod,\n \t\t\t MLX5_GET_HCA_CAP_OP_MOD_QOS_CAP |\ndiff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h\nindex a7e3c39..ab61454 100644\n--- a/drivers/common/mlx5/mlx5_devx_cmds.h\n+++ b/drivers/common/mlx5/mlx5_devx_cmds.h\n@@ -99,6 +99,8 @@ struct mlx5_hca_attr {\n \tuint32_t log_max_static_sq_wq:5; /* Static WQE size SQ. */\n \tuint32_t dev_freq_khz; /* Timestamp counter frequency, kHz. */\n \tuint32_t scatter_fcs_w_decap_disable:1;\n+\tuint32_t regex:1;\n+\tuint32_t regexp_num_of_engines;\n \tstruct mlx5_hca_qos_attr qos;\n \tstruct mlx5_hca_vdpa_attr vdpa;\n };\ndiff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h\nindex d7d6cf8..364db81 100644\n--- a/drivers/common/mlx5/mlx5_prm.h\n+++ b/drivers/common/mlx5/mlx5_prm.h\n@@ -1043,9 +1043,14 @@ struct mlx5_ifc_cmd_hca_cap_bits {\n \tu8 wqe_index_ignore_cap[0x1];\n \tu8 dynamic_qp_allocation[0x1];\n \tu8 log_max_qp[0x5];\n-\tu8 reserved_at_a0[0xb];\n+\tu8 regexp[0x1];\n+\tu8 reserved_at_a1[0x3];\n+\tu8 regexp_num_of_engines[0x4];\n+\tu8 reserved_at_a8[0x3];\n \tu8 log_max_srq[0x5];\n-\tu8 reserved_at_b0[0xb];\n+\tu8 reserved_at_b0[0x3];\n+\tu8 regexp_log_crspace_size[0x5];\n+\tu8 reserved_at_b8[0x3];\n \tu8 scatter_fcs_w_decap_disable[0x1];\n \tu8 reserved_at_bc[0x4];\n \tu8 reserved_at_c0[0x8];\ndiff --git a/drivers/regex/mlx5/Makefile b/drivers/regex/mlx5/Makefile\nindex 4a2f4e0..1bddf21 100644\n--- a/drivers/regex/mlx5/Makefile\n+++ b/drivers/regex/mlx5/Makefile\n@@ -16,6 +16,8 @@ CFLAGS += -g\n CFLAGS += -I$(RTE_SDK)/drivers/common/mlx5\n CFLAGS += -I$(BUILDDIR)/drivers/common/mlx5\n CFLAGS += -I$(RTE_SDK)/drivers/common/mlx5/linux\n+CFLAGS += -I$(RTE_SDK)/drivers/common/mlx5/linux\n+CFLAGS += -I$(BUILDDIR)/drivers/common/mlx5/linux\n CFLAGS += -D_BSD_SOURCE\n CFLAGS += -D_DEFAULT_SOURCE\n CFLAGS += -D_XOPEN_SOURCE=600\ndiff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c\nindex 922c236..fe44429 100644\n--- a/drivers/regex/mlx5/mlx5_regex.c\n+++ b/drivers/regex/mlx5/mlx5_regex.c\n@@ -2,9 +2,181 @@\n  * Copyright 2020 Mellanox Technologies, Ltd\n  */\n \n+#include <rte_malloc.h>\n+#include <rte_log.h>\n+#include <rte_errno.h>\n+#include <rte_bus_pci.h>\n+#include <rte_pci.h>\n+#include <rte_regexdev.h>\n+#include <rte_regexdev_core.h>\n+#include <rte_regexdev_driver.h>\n+\n+#include <rte_bus_mlx5_pci.h>\n+\n+#include <mlx5_glue.h>\n+#include <mlx5_devx_cmds.h>\n+#include <mlx5_prm.h>\n+\n #include \"mlx5_regex.h\"\n #include \"mlx5_regex_utils.h\"\n \n int mlx5_regex_logtype;\n \n+static const struct rte_regexdev_ops mlx5_regexdev_ops = {0};\n+\n+static struct ibv_device *\n+mlx5_regex_get_ib_device_match(struct rte_pci_addr *addr)\n+{\n+\tint n;\n+\tstruct ibv_device **ibv_list = mlx5_glue->get_device_list(&n);\n+\tstruct ibv_device *ibv_match = NULL;\n+\n+\tif (!ibv_list) {\n+\t\trte_errno = ENOSYS;\n+\t\treturn NULL;\n+\t}\n+\twhile (n-- > 0) {\n+\t\tstruct rte_pci_addr pci_addr;\n+\n+\t\tDRV_LOG(DEBUG, \"Checking device \\\"%s\\\"..\", ibv_list[n]->name);\n+\t\tif (mlx5_dev_to_pci_addr(ibv_list[n]->ibdev_path, &pci_addr))\n+\t\t\tcontinue;\n+\t\tif (rte_pci_addr_cmp(addr, &pci_addr))\n+\t\t\tcontinue;\n+\t\tibv_match = ibv_list[n];\n+\t\tbreak;\n+\t}\n+\tif (!ibv_match)\n+\t\trte_errno = ENOENT;\n+\tmlx5_glue->free_device_list(ibv_list);\n+\treturn ibv_match;\n+}\n+\n+static void\n+mlx5_regex_get_name(char *name, struct rte_pci_device *pci_dev __rte_unused)\n+{\n+\tsprintf(name, \"mlx5_regex_%02x:%02x.%02x\", pci_dev->addr.bus,\n+\t\tpci_dev->addr.devid, pci_dev->addr.function);\n+}\n+\n+static int\n+mlx5_regex_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n+\t\t     struct rte_pci_device *pci_dev)\n+{\n+\tstruct ibv_device *ibv;\n+\tstruct mlx5_regex_priv *priv = NULL;\n+\tstruct ibv_context *ctx = NULL;\n+\tstruct mlx5_hca_attr attr;\n+\tchar name[RTE_REGEXDEV_NAME_MAX_LEN];\n+\tint ret;\n+\n+\tibv = mlx5_regex_get_ib_device_match(&pci_dev->addr);\n+\tif (!ibv) {\n+\t\tDRV_LOG(ERR, \"No matching IB device for PCI slot \"\n+\t\t\tPCI_PRI_FMT \".\", pci_dev->addr.domain,\n+\t\t\tpci_dev->addr.bus, pci_dev->addr.devid,\n+\t\t\tpci_dev->addr.function);\n+\t\treturn -rte_errno;\n+\t}\n+\tDRV_LOG(INFO, \"PCI information matches for device \\\"%s\\\".\",\n+\t\tibv->name);\n+\tctx = mlx5_glue->dv_open_device(ibv);\n+\tif (!ctx) {\n+\t\tDRV_LOG(ERR, \"Failed to open IB device \\\"%s\\\".\", ibv->name);\n+\t\trte_errno = ENODEV;\n+\t\treturn -rte_errno;\n+\t}\n+\tret = mlx5_devx_cmd_query_hca_attr(ctx, &attr);\n+\tif (ret) {\n+\t\tDRV_LOG(ERR, \"Unable to read HCA capabilities.\");\n+\t\trte_errno = ENOTSUP;\n+\t\tgoto error;\n+\t} else if (!attr.regex || attr.regexp_num_of_engines == 0) {\n+\t\tDRV_LOG(ERR, \"Not enough capabilities to support RegEx, maybe \"\n+\t\t\t\"old FW/OFED version?\");\n+\t\trte_errno = ENOTSUP;\n+\t\tgoto error;\n+\t}\n+\tpriv = rte_zmalloc(\"mlx5 regex device private\", sizeof(*priv),\n+\t\t\t   RTE_CACHE_LINE_SIZE);\n+\tif (!priv) {\n+\t\tDRV_LOG(ERR, \"Failed to allocate private memory.\");\n+\t\trte_errno = ENOMEM;\n+\t\tgoto error;\n+\t}\n+\tpriv->ctx = ctx;\n+\tmlx5_regex_get_name(name, pci_dev);\n+\tpriv->regexdev = rte_regexdev_register(name);\n+\tif (priv->regexdev == NULL) {\n+\t\tDRV_LOG(ERR, \"Failed to register RegEx device.\");\n+\t\trte_errno = rte_errno ? rte_errno : EINVAL;\n+\t\tgoto error;\n+\t}\n+\tpriv->regexdev->dev_ops = &mlx5_regexdev_ops;\n+\tpriv->regexdev->device = (struct rte_device *)pci_dev;\n+\tpriv->regexdev->data->dev_private = priv;\n+\treturn 0;\n+\n+error:\n+\tif (ctx)\n+\t\tmlx5_glue->close_device(ctx);\n+\tif (priv)\n+\t\trte_free(priv);\n+\treturn -rte_errno;\n+}\n+\n+static int\n+mlx5_regex_pci_remove(struct rte_pci_device *pci_dev)\n+{\n+\tchar name[RTE_REGEXDEV_NAME_MAX_LEN];\n+\tstruct rte_regexdev *dev;\n+\tstruct mlx5_regex_priv *priv = NULL;\n+\n+\tmlx5_regex_get_name(name, pci_dev);\n+\tdev = rte_regexdev_get_device_by_name(name);\n+\tif (!dev)\n+\t\treturn 0;\n+\tpriv = dev->data->dev_private;\n+\tif (priv) {\n+\t\tif (priv->ctx)\n+\t\t\tmlx5_glue->close_device(priv->ctx);\n+\t\tif (priv->regexdev)\n+\t\t\trte_regexdev_unregister(priv->regexdev);\n+\t\trte_free(priv);\n+\t}\n+\treturn 0;\n+}\n+\n+static const struct rte_pci_id mlx5_regex_pci_id_map[] = {\n+\t{\n+\t\tRTE_PCI_DEVICE(PCI_VENDOR_ID_MELLANOX,\n+\t\t\t\tPCI_DEVICE_ID_MELLANOX_CONNECTX6DXBF)\n+\t},\n+\t{\n+\t\t.vendor_id = 0\n+\t}\n+};\n+\n+static struct rte_mlx5_pci_driver mlx5_regex_driver = {\n+\t.dev_class = MLX5_CLASS_REGEX,\n+\t.pci_driver = {\n+\t\t.driver = {\n+\t\t\t.name = \"mlx5_regex\",\n+\t\t},\n+\t\t.id_table = mlx5_regex_pci_id_map,\n+\t\t.probe = mlx5_regex_pci_probe,\n+\t\t.remove = mlx5_regex_pci_remove,\n+\t\t.drv_flags = 0,\n+\t},\n+};\n+\n+RTE_INIT_PRIO(rte_mlx5_regex_init, CLASS)\n+{\n+\tif (mlx5_glue)\n+\t\trte_mlx5_pci_driver_register(&mlx5_regex_driver);\n+}\n+\n RTE_LOG_REGISTER(mlx5_regex_logtype, pmd.regex.mlx5, NOTICE)\n+RTE_PMD_EXPORT_NAME(net_mlx5_regex, __COUNTER__);\n+RTE_PMD_REGISTER_PCI_TABLE(net_mlx5_regex, mlx5_regex_pci_id_map);\n+RTE_PMD_REGISTER_KMOD_DEP(net_mlx5_regex, \"* ib_uverbs & mlx5_core & mlx5_ib\");\ndiff --git a/drivers/regex/mlx5/mlx5_regex.h b/drivers/regex/mlx5/mlx5_regex.h\nindex 0e0495c..0ce1e4d 100644\n--- a/drivers/regex/mlx5/mlx5_regex.h\n+++ b/drivers/regex/mlx5/mlx5_regex.h\n@@ -5,4 +5,10 @@\n #ifndef MLX5_REGEX_H\n #define MLX5_REGEX_H\n \n+struct mlx5_regex_priv {\n+\tTAILQ_ENTRY(mlx5_regex_priv) next;\n+\tstruct ibv_context *ctx; /* Device context. */\n+\tstruct rte_pci_device *pci_dev;\n+\tstruct rte_regexdev *regexdev; /* Pointer to the RegEx dev. */\n+};\n #endif /* MLX5_REGEX_H */\ndiff --git a/mk/rte.app.mk b/mk/rte.app.mk\nindex a7f30c4..5241fbe 100644\n--- a/mk/rte.app.mk\n+++ b/mk/rte.app.mk\n@@ -101,6 +101,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched\n _LDLIBS-$(CONFIG_RTE_LIBRTE_RCU)            += -lrte_rcu\n _LDLIBS-$(CONFIG_RTE_LIBRTE_GRAPH)          += -lrte_graph\n _LDLIBS-$(CONFIG_RTE_LIBRTE_NODE)           += -lrte_node\n+_LDLIBS-$(CONFIG_RTE_LIBRTE_REGEXDEV)       += -lrte_regexdev\n \n ifeq ($(CONFIG_RTE_EXEC_ENV_LINUX),y)\n _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni\n",
    "prefixes": [
        "v6",
        "03/13"
    ]
}