get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 94639,
    "url": "https://patches.dpdk.org/api/patches/94639/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210621150449.19070-15-tduszynski@marvell.com/",
    "project": {
        "id": 1,
        "url": "https://patches.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": "<20210621150449.19070-15-tduszynski@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210621150449.19070-15-tduszynski@marvell.com",
    "date": "2021-06-21T15:04:31",
    "name": "[v3,14/32] raw/cnxk_bphy: support for performing selftest",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "1b0f86268033d116276f98abba568ab68989dd9c",
    "submitter": {
        "id": 2215,
        "url": "https://patches.dpdk.org/api/people/2215/?format=api",
        "name": "Tomasz Duszynski",
        "email": "tduszynski@marvell.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20210621150449.19070-15-tduszynski@marvell.com/mbox/",
    "series": [
        {
            "id": 17426,
            "url": "https://patches.dpdk.org/api/series/17426/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=17426",
            "date": "2021-06-21T15:04:17",
            "name": "add support for baseband phy",
            "version": 3,
            "mbox": "https://patches.dpdk.org/series/17426/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/94639/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/94639/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 10908A0547;\n\tMon, 21 Jun 2021 17:06:48 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 36D19411FB;\n\tMon, 21 Jun 2021 17:05:41 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com\n [67.231.148.174])\n by mails.dpdk.org (Postfix) with ESMTP id 5DDF341205\n for <dev@dpdk.org>; Mon, 21 Jun 2021 17:05:39 +0200 (CEST)",
            "from pps.filterd (m0045849.ppops.net [127.0.0.1])\n by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id\n 15LF5Sdh008602; Mon, 21 Jun 2021 08:05:38 -0700",
            "from dc5-exch02.marvell.com ([199.233.59.182])\n by mx0a-0016f401.pphosted.com with ESMTP id 39aj2xja1c-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);\n Mon, 21 Jun 2021 08:05:38 -0700",
            "from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18;\n Mon, 21 Jun 2021 08:05:37 -0700",
            "from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend\n Transport; Mon, 21 Jun 2021 08:05:37 -0700",
            "from EH-LT0048.marvell.com (unknown [10.193.32.52])\n by maili.marvell.com (Postfix) with ESMTP id 8B5903F705B;\n Mon, 21 Jun 2021 08:05:35 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-transfer-encoding : content-type; s=pfpt0220;\n bh=mZdmoc2KKGutv369TIzFauuBf6PjCpjhUxavn3EgTLA=;\n b=bwiocSmyrYvj8kMkfsN2sT/xxtvjGNN+sB5eI5ZWKYn1UvjlX1AK2eh2bD48EhWTcbc8\n PjLY+HN42Iddoucdxsn2eet9z9lddfFoVpdsc2k3t2fLYurC9QoAEFhjKFROobsgyFx5\n 0mq3MiavDzWaMZOo1tCHr+1CEkXkjkE6u80sj/d8PI/S6cDm4oFW2K4Sn7nCivLyyN99\n iYDAxgYeYF96QBJF/4/GwFCMXh65CsP7LYoU6hOljQxGkEJUAuz0LZaRTJgwNOXFvVJv\n 3xOmew2XNQKURHJGrNdSDMSBhdmFV0Xl1r05SP0Le3STk+011qqLYbqDuYKgVmXQQucG Bg==",
        "From": "Tomasz Duszynski <tduszynski@marvell.com>",
        "To": "Jakub Palider <jpalider@marvell.com>, Tomasz Duszynski\n <tduszynski@marvell.com>",
        "CC": "<thomas@monjalon.net>, <dev@dpdk.org>, Jerin Jacob <jerinj@marvell.com>",
        "Date": "Mon, 21 Jun 2021 17:04:31 +0200",
        "Message-ID": "<20210621150449.19070-15-tduszynski@marvell.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20210621150449.19070-1-tduszynski@marvell.com>",
        "References": "<20210531214142.30167-1-tduszynski@marvell.com>\n <20210621150449.19070-1-tduszynski@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Proofpoint-GUID": "Kcllp8D5o0iSaoG8G2OIWl0WWwWcaywg",
        "X-Proofpoint-ORIG-GUID": "Kcllp8D5o0iSaoG8G2OIWl0WWwWcaywg",
        "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790\n definitions=2021-06-21_06:2021-06-21,\n 2021-06-21 signatures=0",
        "Subject": "[dpdk-dev] [PATCH v3 14/32] raw/cnxk_bphy: support for performing\n selftest",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add support for performing selftest operation.\n\nSigned-off-by: Tomasz Duszynski <tduszynski@marvell.com>\nSigned-off-by: Jakub Palider <jpalider@marvell.com>\nReviewed-by: Jerin Jacob <jerinj@marvell.com>\n---\n doc/guides/rawdevs/cnxk_bphy.rst           |  19 +-\n drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c      |   2 +\n drivers/raw/cnxk_bphy/cnxk_bphy_cgx.h      |  10 +\n drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c | 206 +++++++++++++++++++++\n drivers/raw/cnxk_bphy/meson.build          |   1 +\n 5 files changed, 237 insertions(+), 1 deletion(-)\n create mode 100644 drivers/raw/cnxk_bphy/cnxk_bphy_cgx.h\n create mode 100644 drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c",
    "diff": "diff --git a/doc/guides/rawdevs/cnxk_bphy.rst b/doc/guides/rawdevs/cnxk_bphy.rst\nindex 0d842a831..120f953fb 100644\n--- a/doc/guides/rawdevs/cnxk_bphy.rst\n+++ b/doc/guides/rawdevs/cnxk_bphy.rst\n@@ -38,7 +38,8 @@ To perform data transfer use standard ``rte_rawdev_enqueue_buffers()`` and\n responses hence dequeueing is not always necessary.\n \n BPHY CGX/RPM PMD accepts ``struct cnxk_bphy_cgx_msg`` messages which differ by type and payload.\n-Message types along with description are listed below.\n+Message types along with description are listed below. As for the usage examples please refer to\n+``cnxk_bphy_cgx_dev_selftest()``.\n \n Get link information\n ~~~~~~~~~~~~~~~~~~~~\n@@ -93,3 +94,19 @@ Message is used to start or stop accepting traffic.\n Message must have type set to ``CNXK_BPHY_CGX_MSG_TYPE_START_RXTX`` or\n ``CNXK_BPHY_CGX_MSG_TYPE_STOP_RXTX``. Former will enable traffic while the latter will\n do the opposite.\n+\n+Self test\n+---------\n+\n+On EAL initialization, BPHY CGX/RPM devices will be probed and populated into\n+the raw devices. The rawdev ID of the device can be obtained using invocation\n+of ``rte_rawdev_get_dev_id(\"NAME:x\")`` from the test application, where:\n+\n+- NAME is the desired subsystem: use \"BPHY_CGX\" for\n+  RFOE module,\n+- x is the device's bus id specified in \"bus:device.func\" (BDF) format.\n+\n+Use this identifier for further rawdev function calls.\n+\n+The driver's selftest rawdev API can be used to verify the BPHY CGX/RPM\n+functionality.\ndiff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c\nindex a8eafae1b..3da224414 100644\n--- a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c\n+++ b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c\n@@ -9,6 +9,7 @@\n \n #include <roc_api.h>\n \n+#include \"cnxk_bphy_cgx.h\"\n #include \"rte_pmd_bphy.h\"\n \n struct cnxk_bphy_cgx_queue {\n@@ -196,6 +197,7 @@ static const struct rte_rawdev_ops cnxk_bphy_cgx_rawdev_ops = {\n \t.enqueue_bufs = cnxk_bphy_cgx_enqueue_bufs,\n \t.dequeue_bufs = cnxk_bphy_cgx_dequeue_bufs,\n \t.queue_count = cnxk_bphy_cgx_queue_count,\n+\t.dev_selftest = cnxk_bphy_cgx_dev_selftest,\n };\n \n static void\ndiff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.h b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.h\nnew file mode 100644\nindex 000000000..fb6b31bf4\n--- /dev/null\n+++ b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.h\n@@ -0,0 +1,10 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2021 Marvell.\n+ */\n+\n+#ifndef _CNXK_BPHY_CGX_H_\n+#define _CNXK_BPHY_CGX_H_\n+\n+int cnxk_bphy_cgx_dev_selftest(uint16_t dev_id);\n+\n+#endif /* _CNXK_BPHY_CGX_H_ */\ndiff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c\nnew file mode 100644\nindex 000000000..cb4dd4b22\n--- /dev/null\n+++ b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c\n@@ -0,0 +1,206 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2021 Marvell.\n+ */\n+#include <stdint.h>\n+\n+#include <rte_cycles.h>\n+#include <rte_log.h>\n+#include <rte_malloc.h>\n+#include <rte_rawdev.h>\n+\n+#include \"cnxk_bphy_cgx.h\"\n+#include \"rte_pmd_bphy.h\"\n+\n+static int\n+cnxk_bphy_cgx_enq_msg(uint16_t dev_id, unsigned int queue, void *msg)\n+{\n+\tstruct rte_rawdev_buf *bufs[1];\n+\tstruct rte_rawdev_buf buf;\n+\tvoid *q;\n+\tint ret;\n+\n+\tq = (void *)(size_t)queue;\n+\tbuf.buf_addr = msg;\n+\tbufs[0] = &buf;\n+\n+\tret = rte_rawdev_enqueue_buffers(dev_id, bufs, 1, q);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\tif (ret != 1)\n+\t\treturn -EIO;\n+\n+\treturn 0;\n+}\n+\n+static int\n+cnxk_bphy_cgx_deq_msg(uint16_t dev_id, unsigned int queue, void **msg)\n+{\n+\tstruct rte_rawdev_buf *bufs[1];\n+\tstruct rte_rawdev_buf buf;\n+\tvoid *q;\n+\tint ret;\n+\n+\tq = (void *)(size_t)queue;\n+\tbufs[0] = &buf;\n+\n+\tret = rte_rawdev_dequeue_buffers(dev_id, bufs, 1, q);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\tif (ret != 1)\n+\t\treturn -EIO;\n+\n+\t*msg = buf.buf_addr;\n+\n+\treturn 0;\n+}\n+\n+static int\n+cnxk_bphy_cgx_link_cond(uint16_t dev_id, unsigned int queue, int cond)\n+{\n+\tint tries = 10, ret;\n+\n+\tdo {\n+\t\tstruct cnxk_bphy_cgx_msg_link_info *link_info = NULL;\n+\t\tstruct cnxk_bphy_cgx_msg msg;\n+\n+\t\tmsg.type = CNXK_BPHY_CGX_MSG_TYPE_GET_LINKINFO;\n+\t\tret = cnxk_bphy_cgx_enq_msg(dev_id, queue, &msg);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\tret = cnxk_bphy_cgx_deq_msg(dev_id, queue, (void **)&link_info);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\tif (link_info->link_up == cond) {\n+\t\t\trte_free(link_info);\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\trte_free(link_info);\n+\t\trte_delay_ms(500);\n+\t} while (--tries);\n+\n+\tif (tries)\n+\t\treturn !!cond;\n+\n+\treturn -ETIMEDOUT;\n+}\n+\n+int\n+cnxk_bphy_cgx_dev_selftest(uint16_t dev_id)\n+{\n+\tunsigned int queues, i;\n+\tint ret;\n+\n+\tqueues = rte_rawdev_queue_count(dev_id);\n+\tif (queues == 0)\n+\t\treturn -ENODEV;\n+\n+\tret = rte_rawdev_start(dev_id);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tfor (i = 0; i < queues; i++) {\n+\t\tstruct cnxk_bphy_cgx_msg_set_link_state link_state;\n+\t\tstruct cnxk_bphy_cgx_msg msg;\n+\t\tunsigned int descs;\n+\n+\t\tret = rte_rawdev_queue_conf_get(dev_id, i, &descs,\n+\t\t\t\t\t\tsizeof(descs));\n+\t\tif (ret)\n+\t\t\tbreak;\n+\t\tif (descs != 1) {\n+\t\t\tRTE_LOG(ERR, PMD, \"Wrong number of descs reported\\n\");\n+\t\t\tret = -ENODEV;\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tRTE_LOG(INFO, PMD, \"Testing queue %d\\n\", i);\n+\n+\t\t/* stop rx/tx */\n+\t\tmsg.type = CNXK_BPHY_CGX_MSG_TYPE_STOP_RXTX;\n+\t\tret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);\n+\t\tif (ret) {\n+\t\t\tRTE_LOG(ERR, PMD, \"Failed to stop rx/tx\\n\");\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\t/* start rx/tx */\n+\t\tmsg.type = CNXK_BPHY_CGX_MSG_TYPE_START_RXTX;\n+\t\tret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);\n+\t\tif (ret) {\n+\t\t\tRTE_LOG(ERR, PMD, \"Failed to start rx/tx\\n\");\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\t/* set link down */\n+\t\tlink_state.state = false;\n+\t\tmsg.type = CNXK_BPHY_CGX_MSG_TYPE_SET_LINK_STATE;\n+\t\tmsg.data = &link_state;\n+\t\tret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);\n+\t\tif (ret) {\n+\t\t\tRTE_LOG(ERR, PMD, \"Failed to set link down\\n\");\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tret = cnxk_bphy_cgx_link_cond(dev_id, i, 0);\n+\t\tif (ret != 0)\n+\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\t\"Timed out waiting for a link down\\n\");\n+\n+\t\t/* set link up */\n+\t\tlink_state.state = true;\n+\t\tmsg.type = CNXK_BPHY_CGX_MSG_TYPE_SET_LINK_STATE;\n+\t\tmsg.data = &link_state;\n+\t\tret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);\n+\t\tif (ret) {\n+\t\t\tRTE_LOG(ERR, PMD, \"Failed to set link up\\n\");\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tret = cnxk_bphy_cgx_link_cond(dev_id, i, 1);\n+\t\tif (ret != 1)\n+\t\t\tRTE_LOG(ERR, PMD, \"Timed out waiting for a link up\\n\");\n+\n+\t\t/* enable internal loopback */\n+\t\tmsg.type = CNXK_BPHY_CGX_MSG_TYPE_INTLBK_ENABLE;\n+\t\tret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);\n+\t\tif (ret) {\n+\t\t\tRTE_LOG(ERR, PMD, \"Failed to enable internal lbk\\n\");\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\t/* disable internal loopback */\n+\t\tmsg.type = CNXK_BPHY_CGX_MSG_TYPE_INTLBK_DISABLE;\n+\t\tret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);\n+\t\tif (ret) {\n+\t\t\tRTE_LOG(ERR, PMD, \"Failed to disable internal lbk\\n\");\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\t/* enable ptp */\n+\t\tmsg.type = CNXK_BPHY_CGX_MSG_TYPE_PTP_RX_ENABLE;\n+\t\tret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);\n+\t\t/* ptp not available on RPM */\n+\t\tif (ret < 0 && ret != -ENOTSUP) {\n+\t\t\tRTE_LOG(ERR, PMD, \"Failed to enable ptp\\n\");\n+\t\t\tbreak;\n+\t\t}\n+\t\tret = 0;\n+\n+\t\t/* disable ptp */\n+\t\tmsg.type = CNXK_BPHY_CGX_MSG_TYPE_PTP_RX_DISABLE;\n+\t\tret = cnxk_bphy_cgx_enq_msg(dev_id, i, &msg);\n+\t\t/* ptp not available on RPM */\n+\t\tif (ret < 0 && ret != -ENOTSUP) {\n+\t\t\tRTE_LOG(ERR, PMD, \"Failed to disable ptp\\n\");\n+\t\t\tbreak;\n+\t\t}\n+\t\tret = 0;\n+\t}\n+\n+\trte_rawdev_stop(dev_id);\n+\n+\treturn ret;\n+}\ndiff --git a/drivers/raw/cnxk_bphy/meson.build b/drivers/raw/cnxk_bphy/meson.build\nindex 0d65fc5c8..dc5558ee8 100644\n--- a/drivers/raw/cnxk_bphy/meson.build\n+++ b/drivers/raw/cnxk_bphy/meson.build\n@@ -5,5 +5,6 @@\n deps += ['bus_pci', 'common_cnxk', 'rawdev']\n sources = files(\n         'cnxk_bphy_cgx.c',\n+        'cnxk_bphy_cgx_test.c',\n )\n headers = files('rte_pmd_bphy.h')\n",
    "prefixes": [
        "v3",
        "14/32"
    ]
}