get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 130176,
    "url": "http://patchwork.dpdk.org/api/patches/130176/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20230811163419.165790-6-hkalra@marvell.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": "<20230811163419.165790-6-hkalra@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230811163419.165790-6-hkalra@marvell.com",
    "date": "2023-08-11T16:34:15",
    "name": "[5/9] net/cnxk: add representor control plane",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "4689a49bb1332dddee07d2cb535623c4e49c970a",
    "submitter": {
        "id": 1182,
        "url": "http://patchwork.dpdk.org/api/people/1182/?format=api",
        "name": "Harman Kalra",
        "email": "hkalra@marvell.com"
    },
    "delegate": {
        "id": 310,
        "url": "http://patchwork.dpdk.org/api/users/310/?format=api",
        "username": "jerin",
        "first_name": "Jerin",
        "last_name": "Jacob",
        "email": "jerinj@marvell.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20230811163419.165790-6-hkalra@marvell.com/mbox/",
    "series": [
        {
            "id": 29193,
            "url": "http://patchwork.dpdk.org/api/series/29193/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=29193",
            "date": "2023-08-11T16:34:10",
            "name": "net/cnxk: support for port representors",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/29193/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/130176/comments/",
    "check": "warning",
    "checks": "http://patchwork.dpdk.org/api/patches/130176/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 207BA43036;\n\tFri, 11 Aug 2023 18:35:36 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 293BF43272;\n\tFri, 11 Aug 2023 18:35:14 +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 5741B43263\n for <dev@dpdk.org>; Fri, 11 Aug 2023 18:35:12 +0200 (CEST)",
            "from pps.filterd (m0045849.ppops.net [127.0.0.1])\n by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id\n 37BBmUgn001610 for <dev@dpdk.org>; Fri, 11 Aug 2023 09:35:11 -0700",
            "from dc5-exch02.marvell.com ([199.233.59.182])\n by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3sd8ypb91u-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)\n for <dev@dpdk.org>; Fri, 11 Aug 2023 09:35:10 -0700",
            "from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48;\n Fri, 11 Aug 2023 09:35:07 -0700",
            "from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend\n Transport; Fri, 11 Aug 2023 09:35:07 -0700",
            "from localhost.localdomain (unknown [10.29.52.211])\n by maili.marvell.com (Postfix) with ESMTP id 729BD3F705D;\n Fri, 11 Aug 2023 09:35:05 -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-type; s=pfpt0220; bh=t7DTeBJCxxvXtrbrs+d4wXFn6oNkKJL1grifnzCPxb8=;\n b=B2MvHyVkmnpY51CLwEStaa5vvrM4+rDmvToaPDEoaopvLZcrTpRbFutFWs0jyD2hPfzY\n 879QHBtnuiMxbNaOAiSFSd6dehGcbNW9YigyGKPbR3R/dreAlqEvIOqW0R2IqAjd6eyc\n CnvUqdQNvstAz51an5fuXqcBArE+l+WpTh9OwDiEeBk7k7zzrRI2ck5CnxxCCsljbLmz\n SIO4MjhtRPnd5JQ+qG5fBWbJ3g8W3bYT5n/M+4lEe2EXt9kYx31DX9lWVbpMgJPaghVS\n 7SeH+ROEeClM6uqVgtxBPZyiFEkzkbQ29prUFuUvw6Lu/mJ3tRFX5FBUBMV5l4jGTmOf 3A==",
        "From": "Harman Kalra <hkalra@marvell.com>",
        "To": "<jerinj@marvell.com>, Nithin Dabilpuram <ndabilpuram@marvell.com>, \"Kiran\n Kumar K\" <kirankumark@marvell.com>, Sunil Kumar Kori <skori@marvell.com>,\n Satha Rao <skoteshwar@marvell.com>",
        "CC": "<dev@dpdk.org>, Harman Kalra <hkalra@marvell.com>",
        "Subject": "[PATCH 5/9] net/cnxk: add representor control plane",
        "Date": "Fri, 11 Aug 2023 22:04:15 +0530",
        "Message-ID": "<20230811163419.165790-6-hkalra@marvell.com>",
        "X-Mailer": "git-send-email 2.18.0",
        "In-Reply-To": "<20230811163419.165790-1-hkalra@marvell.com>",
        "References": "<20230811163419.165790-1-hkalra@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Proofpoint-ORIG-GUID": "sSE1Y2BCVuQb7HV5u9zb_mr76dW7GwTo",
        "X-Proofpoint-GUID": "sSE1Y2BCVuQb7HV5u9zb_mr76dW7GwTo",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26\n definitions=2023-08-11_08,2023-08-10_01,2023-05-22_02",
        "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"
    },
    "content": "Implementing the control path for representor ports, where represented\nports can be configured using TLV messaging.\n\nSigned-off-by: Harman Kalra <hkalra@marvell.com>\n---\n drivers/net/cnxk/cnxk_ethdev.c  |   8 +\n drivers/net/cnxk/cnxk_ethdev.h  |   3 +\n drivers/net/cnxk/cnxk_rep.c     |  13 +-\n drivers/net/cnxk/cnxk_rep.h     |   1 +\n drivers/net/cnxk/cnxk_rep_msg.c | 559 ++++++++++++++++++++++++++++++++\n drivers/net/cnxk/cnxk_rep_msg.h |  78 +++++\n drivers/net/cnxk/meson.build    |   1 +\n 7 files changed, 662 insertions(+), 1 deletion(-)\n create mode 100644 drivers/net/cnxk/cnxk_rep_msg.c\n create mode 100644 drivers/net/cnxk/cnxk_rep_msg.h",
    "diff": "diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c\nindex 902e6df72d..a63c020c0e 100644\n--- a/drivers/net/cnxk/cnxk_ethdev.c\n+++ b/drivers/net/cnxk/cnxk_ethdev.c\n@@ -1645,6 +1645,14 @@ cnxk_nix_dev_stop(struct rte_eth_dev *eth_dev)\n \tmemset(&link, 0, sizeof(link));\n \trte_eth_linkstatus_set(eth_dev, &link);\n \n+\t/* Exiting the rep msg ctrl thread */\n+\tif (dev->num_reps) {\n+\t\tif (dev->start_rep_thread) {\n+\t\t\tdev->start_rep_thread = false;\n+\t\t\tpthread_join(dev->rep_ctrl_msg_thread, NULL);\n+\t\t}\n+\t}\n+\n \treturn 0;\n }\n \ndiff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h\nindex 3896db38e1..0a1a4e377d 100644\n--- a/drivers/net/cnxk/cnxk_ethdev.h\n+++ b/drivers/net/cnxk/cnxk_ethdev.h\n@@ -425,6 +425,9 @@ struct cnxk_eth_dev {\n \tuint16_t switch_domain_id;\n \tuint16_t num_reps;\n \tuint16_t rep_xport_vdev;\n+\trte_spinlock_t rep_lock;\n+\tbool start_rep_thread;\n+\tpthread_t rep_ctrl_msg_thread;\n \tstruct cnxk_rep_info *rep_info;\n };\n \ndiff --git a/drivers/net/cnxk/cnxk_rep.c b/drivers/net/cnxk/cnxk_rep.c\nindex 4dd564058c..e6f5790adc 100644\n--- a/drivers/net/cnxk/cnxk_rep.c\n+++ b/drivers/net/cnxk/cnxk_rep.c\n@@ -2,6 +2,7 @@\n  * Copyright(C) 2023 Marvell.\n  */\n #include <cnxk_rep.h>\n+#include <cnxk_rep_msg.h>\n \n /* CNXK platform representor dev ops */\n struct eth_dev_ops cnxk_rep_dev_ops = {\n@@ -203,7 +204,7 @@ cnxk_process_representor_status(void *roc_nix, uint16_t pf_func, uint8_t op)\n \tcase 0: /* update pffunc of vf being represented */\n \t\tmatch = 0;\n \t\tfunc_val = pf_func;\n-\t\tis_vf_active = true;\n+\t\tis_vf_active = false;\n \t\tbreak;\n \tcase 1: /* check if any representor is representing pffunc */\n \t\tmatch = pf_func;\n@@ -314,6 +315,9 @@ cnxk_rep_dev_probe(struct rte_pci_device *pci_dev, struct rte_eth_dev *pf_ethdev\n \t\tpf_dev->num_reps++;\n \t}\n \n+\t/* Spinlock for synchronization between the control messages */\n+\tplt_spinlock_init(&pf_dev->rep_lock);\n+\n \t/* Register up msg callbacks for processing representor information */\n \tif (roc_nix_process_rep_state_cb_register(&pf_dev->nix, cnxk_process_representor_status)) {\n \t\tplt_err(\"Failed to register callback for representor status\");\n@@ -321,6 +325,13 @@ cnxk_rep_dev_probe(struct rte_pci_device *pci_dev, struct rte_eth_dev *pf_ethdev\n \t\tgoto err;\n \t}\n \n+\t/* Launch a thread to handle control messages */\n+\trc = cnxk_rep_control_thread_launch(pf_dev);\n+\tif (rc) {\n+\t\tplt_err(\"Failed to launch message ctrl thread\");\n+\t\tgoto err;\n+\t}\n+\n \treturn 0;\n err:\n \treturn rc;\ndiff --git a/drivers/net/cnxk/cnxk_rep.h b/drivers/net/cnxk/cnxk_rep.h\nindex e3fc717a58..8825fa1cf2 100644\n--- a/drivers/net/cnxk/cnxk_rep.h\n+++ b/drivers/net/cnxk/cnxk_rep.h\n@@ -8,6 +8,7 @@\n \n #define CNXK_REP_XPORT_VDEV_DEVARGS \"role=server\"\n #define CNXK_REP_XPORT_VDEV_NAME\t   \"net_memif\"\n+#define CNXK_REP_VDEV_CTRL_QUEUE   0\n #define CNXK_MAX_REP_PORTS\t   128\n \n /* Common ethdev ops */\ndiff --git a/drivers/net/cnxk/cnxk_rep_msg.c b/drivers/net/cnxk/cnxk_rep_msg.c\nnew file mode 100644\nindex 0000000000..ca3b6b014e\n--- /dev/null\n+++ b/drivers/net/cnxk/cnxk_rep_msg.c\n@@ -0,0 +1,559 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2023 Marvell.\n+ */\n+\n+#include <cnxk_rep.h>\n+#include <cnxk_rep_msg.h>\n+\n+#define CTRL_MSG_RCV_TIMEOUT_MS 2000\n+#define CTRL_MSG_READY_WAIT_US\t2000\n+#define CTRL_MSG_THRD_NAME_LEN\t35\n+#define CTRL_MSG_BUFFER_SZ\t1500\n+#define CTRL_MSG_SIGNATURE\t0xcdacdeadbeefcadc\n+\n+static int\n+send_message(void *buffer, size_t len, struct rte_mempool *mb_pool, uint16_t portid)\n+{\n+\tstruct rte_mbuf *m = NULL;\n+\tuint8_t nb_pkt;\n+\tint rc = 0;\n+\tchar *data;\n+\n+\tm = rte_pktmbuf_alloc(mb_pool);\n+\tif (m == NULL) {\n+\t\tplt_err(\"Cannot allocate mbuf\");\n+\t\trc = -rte_errno;\n+\t\tgoto fail;\n+\t}\n+\n+\tif (rte_pktmbuf_pkt_len(m) != 0) {\n+\t\tplt_err(\"Bad length\");\n+\t\trc = -EINVAL;\n+\t\tgoto fail;\n+\t}\n+\n+\t/* append data */\n+\tdata = rte_pktmbuf_append(m, len);\n+\tif (data == NULL) {\n+\t\tplt_err(\"Cannot append data\\n\");\n+\t\trc = -EINVAL;\n+\t\tgoto fail;\n+\t}\n+\tif (rte_pktmbuf_pkt_len(m) != len) {\n+\t\tplt_err(\"Bad pkt length\\n\");\n+\t\trc = -EINVAL;\n+\t\tgoto fail;\n+\t}\n+\n+\tif (rte_pktmbuf_data_len(m) != len) {\n+\t\tplt_err(\"Bad data length\\n\");\n+\t\trc = -EINVAL;\n+\t\tgoto fail;\n+\t}\n+\n+\trte_memcpy(data, buffer, len);\n+\n+\t/* Send the control message */\n+\tnb_pkt = rte_eth_tx_burst(portid, CNXK_REP_VDEV_CTRL_QUEUE, (struct rte_mbuf **)&m, 1);\n+\tif (nb_pkt == 0) {\n+\t\tplt_err(\"Failed to send message\");\n+\t\trc = -EINVAL;\n+\t\tgoto fail;\n+\t}\n+\n+\treturn 0;\n+fail:\n+\treturn rc;\n+}\n+\n+void\n+cnxk_rep_msg_populate_msg_end(void *buffer, uint32_t *length)\n+{\n+\tcnxk_rep_msg_populate_command(buffer, length, CNXK_REP_MSG_END, 0);\n+}\n+\n+void\n+cnxk_rep_msg_populate_type(void *buffer, uint32_t *length, cnxk_type_t type, uint32_t sz)\n+{\n+\tuint32_t len = *length;\n+\tcnxk_type_data_t data;\n+\n+\t/* Prepare type data */\n+\tdata.type = type;\n+\tdata.length = sz;\n+\n+\t/* Populate the type data */\n+\trte_memcpy(RTE_PTR_ADD(buffer, len), &data, sizeof(cnxk_type_data_t));\n+\tlen += sizeof(cnxk_type_data_t);\n+\n+\t*length = len;\n+}\n+\n+void\n+cnxk_rep_msg_populate_header(void *buffer, uint32_t *length)\n+{\n+\tcnxk_header_t hdr;\n+\tint len;\n+\n+\tcnxk_rep_msg_populate_type(buffer, length, CNXK_TYPE_HEADER, sizeof(cnxk_header_t));\n+\n+\tlen = *length;\n+\t/* Prepare header data */\n+\thdr.signature = CTRL_MSG_SIGNATURE;\n+\n+\t/* Populate header data */\n+\trte_memcpy(RTE_PTR_ADD(buffer, len), &hdr, sizeof(cnxk_header_t));\n+\tlen += sizeof(cnxk_header_t);\n+\n+\t*length = len;\n+}\n+\n+void\n+cnxk_rep_msg_populate_command(void *buffer, uint32_t *length, cnxk_rep_msg_t type, uint32_t size)\n+{\n+\tcnxk_rep_msg_data_t msg_data;\n+\tuint32_t len;\n+\tuint16_t sz = sizeof(cnxk_rep_msg_data_t);\n+\n+\tcnxk_rep_msg_populate_type(buffer, length, CNXK_TYPE_MSG, sz);\n+\n+\tlen = *length;\n+\t/* Prepare command data */\n+\tmsg_data.type = type;\n+\tmsg_data.length = size;\n+\n+\t/* Populate the command */\n+\trte_memcpy(RTE_PTR_ADD(buffer, len), &msg_data, sz);\n+\tlen += sz;\n+\n+\t*length = len;\n+}\n+\n+void\n+cnxk_rep_msg_populate_command_meta(void *buffer, uint32_t *length, void *msg_meta, uint32_t sz,\n+\t\t\t\t   cnxk_rep_msg_t msg)\n+{\n+\tuint32_t len;\n+\n+\tcnxk_rep_msg_populate_command(buffer, length, msg, sz);\n+\n+\tlen = *length;\n+\t/* Populate command data */\n+\trte_memcpy(RTE_PTR_ADD(buffer, len), msg_meta, sz);\n+\tlen += sz;\n+\n+\t*length = len;\n+}\n+\n+static int\n+parse_validate_header(void *msg_buf, uint32_t *buf_trav_len)\n+{\n+\tcnxk_type_data_t *tdata = NULL;\n+\tcnxk_header_t *hdr = NULL;\n+\tvoid *data = NULL;\n+\tuint16_t len = 0;\n+\n+\t/* Read first bytes of type data */\n+\tdata = msg_buf;\n+\ttdata = (cnxk_type_data_t *)data;\n+\tif (tdata->type != CNXK_TYPE_HEADER) {\n+\t\tplt_err(\"Invalid type %d, type header expected\", tdata->type);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* Get the header value */\n+\tdata = RTE_PTR_ADD(msg_buf, sizeof(cnxk_type_data_t));\n+\tlen += sizeof(cnxk_type_data_t);\n+\n+\t/* Validate the header */\n+\thdr = (cnxk_header_t *)data;\n+\tif (hdr->signature != CTRL_MSG_SIGNATURE) {\n+\t\tplt_err(\"Invalid signature detected: 0x%lx\", hdr->signature);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* Update length read till point */\n+\tlen += tdata->length;\n+\n+\t*buf_trav_len = len;\n+\treturn 0;\n+fail:\n+\treturn errno;\n+}\n+\n+static cnxk_rep_msg_data_t *\n+message_data_extract(void *msg_buf, uint32_t *buf_trav_len)\n+{\n+\tcnxk_type_data_t *tdata = NULL;\n+\tcnxk_rep_msg_data_t *msg = NULL;\n+\tuint16_t len = *buf_trav_len;\n+\tvoid *data;\n+\n+\ttdata = (cnxk_type_data_t *)RTE_PTR_ADD(msg_buf, len);\n+\tif (tdata->type != CNXK_TYPE_MSG) {\n+\t\tplt_err(\"Invalid type %d, type MSG expected\", tdata->type);\n+\t\tgoto fail;\n+\t}\n+\n+\t/* Get the message type */\n+\tlen += sizeof(cnxk_type_data_t);\n+\tdata = RTE_PTR_ADD(msg_buf, len);\n+\tmsg = (cnxk_rep_msg_data_t *)data;\n+\n+\t/* Advance to actual message data */\n+\tlen += tdata->length;\n+\t*buf_trav_len = len;\n+\n+\treturn msg;\n+fail:\n+\treturn NULL;\n+}\n+\n+static void\n+process_ack_message(void *msg_buf, uint32_t *buf_trav_len, uint32_t msg_len, void *data)\n+{\n+\tcnxk_rep_msg_ack_data_t *adata = (cnxk_rep_msg_ack_data_t *)data;\n+\tuint16_t len = *buf_trav_len;\n+\tvoid *buf;\n+\n+\t/* Get the message type data viz ack data */\n+\tbuf = RTE_PTR_ADD(msg_buf, len);\n+\tadata->u.data = rte_zmalloc(\"Ack data\", msg_len, 0);\n+\tadata->size = msg_len;\n+\tif (adata->size == sizeof(uint64_t))\n+\t\trte_memcpy(&adata->u.data, buf, msg_len);\n+\telse\n+\t\trte_memcpy(adata->u.data, buf, msg_len);\n+\tplt_rep_dbg(\"Address %p val 0x%lx sval %ld msg_len %d\", adata->u.data, adata->u.val,\n+\t\t    adata->u.sval, msg_len);\n+\n+\t/* Advance length to nex message */\n+\tlen += msg_len;\n+\t*buf_trav_len = len;\n+}\n+\n+static int\n+notify_rep_dev_ready(void *data, bool state)\n+{\n+\tstruct cnxk_eth_dev *pf_dev = (struct cnxk_eth_dev *)data;\n+\tstruct cnxk_rep_dev *rep_dev = NULL;\n+\tstruct rte_eth_dev *rep_eth_dev;\n+\tint i;\n+\n+\tfor (i = 0; i < pf_dev->num_reps; i++) {\n+\t\trep_eth_dev = pf_dev->rep_info[i].rep_eth_dev;\n+\t\tif (!rep_eth_dev)\n+\t\t\tcontinue;\n+\n+\t\trep_dev = cnxk_rep_pmd_priv(rep_eth_dev);\n+\t\trep_dev->is_vf_active = state;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static void\n+process_ready_message(void *msg_buf, uint32_t *buf_trav_len, uint32_t msg_len, void *data)\n+{\n+\tcnxk_rep_msg_ready_data_t *rdata = NULL;\n+\tuint16_t len = *buf_trav_len;\n+\tvoid *buf;\n+\n+\t/* Get the message type data viz ready data */\n+\tbuf = RTE_PTR_ADD(msg_buf, len);\n+\trdata = (cnxk_rep_msg_ready_data_t *)buf;\n+\n+\tplt_rep_dbg(\"Ready data received %d\", rdata->val);\n+\n+\t/* Wait required to ensure other side ready for recieving the ack */\n+\tusleep(CTRL_MSG_READY_WAIT_US);\n+\t/* Update all representor about ready message */\n+\tif (rdata->val)\n+\t\tnotify_rep_dev_ready(data, true);\n+\n+\t/* Advance length to nex message */\n+\tlen += msg_len;\n+\t*buf_trav_len = len;\n+}\n+\n+static void\n+process_exit_message(void *msg_buf, uint32_t *buf_trav_len, uint32_t msg_len, void *data)\n+{\n+\tcnxk_rep_msg_exit_data_t *edata = NULL;\n+\tuint16_t len = *buf_trav_len;\n+\tvoid *buf;\n+\n+\t/* Get the message type data viz exit data */\n+\tbuf = RTE_PTR_ADD(msg_buf, len);\n+\tedata = (cnxk_rep_msg_exit_data_t *)buf;\n+\n+\tplt_rep_dbg(\"Exit data received %d\", edata->val);\n+\n+\t/* Update all representor about ready/exit message */\n+\tif (edata->val)\n+\t\tnotify_rep_dev_ready(data, false);\n+\n+\t/* Advance length to nex message */\n+\tlen += msg_len;\n+\t*buf_trav_len = len;\n+}\n+\n+static void\n+populate_ack_msg(void *buffer, uint32_t *length, cnxk_rep_msg_ack_data_t *adata)\n+{\n+\tuint32_t sz = sizeof(cnxk_rep_msg_ack_data_t);\n+\tuint32_t len;\n+\n+\tcnxk_rep_msg_populate_command(buffer, length, CNXK_REP_MSG_ACK, sz);\n+\n+\tlen = *length;\n+\n+\trte_memcpy(RTE_PTR_ADD(buffer, len), adata, sz);\n+\n+\tlen += sz;\n+\n+\t*length = len;\n+}\n+\n+static int\n+send_ack_message(cnxk_rep_msg_ack_data_t *adata, struct rte_mempool *mb_pool, uint16_t portid)\n+{\n+\tuint32_t len = 0, size;\n+\tvoid *buffer;\n+\tint rc = 0;\n+\n+\t/* Allocate memory for preparing a message */\n+\tsize = CTRL_MSG_BUFFER_SZ;\n+\tbuffer = rte_zmalloc(\"ACK msg\", size, 0);\n+\tif (!buffer) {\n+\t\tplt_err(\"Failed to allocate mem\");\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\t/* Prepare the ACK message */\n+\tcnxk_rep_msg_populate_header(buffer, &len);\n+\tpopulate_ack_msg(buffer, &len, adata);\n+\tcnxk_rep_msg_populate_msg_end(buffer, &len);\n+\n+\t/* Send it to the peer */\n+\trc = send_message(buffer, len, mb_pool, portid);\n+\tif (rc)\n+\t\tplt_err(\"Failed send ack\");\n+\n+\treturn rc;\n+}\n+\n+static int\n+process_message(void *msg_buf, uint32_t *buf_trav_len, void *data, struct rte_mempool *mb_pool,\n+\t\tuint16_t portid)\n+{\n+\tcnxk_rep_msg_data_t *msg = NULL;\n+\tcnxk_rep_msg_ack_data_t adata;\n+\tbool send_ack;\n+\tint rc = 0;\n+\n+\t/* Get the message data */\n+\tmsg = message_data_extract(msg_buf, buf_trav_len);\n+\tif (!msg) {\n+\t\tplt_err(\"Failed to get message data\");\n+\t\trc = -EINVAL;\n+\t\tgoto fail;\n+\t}\n+\n+\t/* Different message type processing */\n+\twhile (msg->type != CNXK_REP_MSG_END) {\n+\t\tsend_ack = true;\n+\t\tswitch (msg->type) {\n+\t\tcase CNXK_REP_MSG_ACK:\n+\t\t\tprocess_ack_message(msg_buf, buf_trav_len, msg->length, data);\n+\t\t\tsend_ack = false;\n+\t\t\tbreak;\n+\t\tcase CNXK_REP_MSG_READY:\n+\t\t\tprocess_ready_message(msg_buf, buf_trav_len, msg->length, data);\n+\t\t\tadata.type = CNXK_REP_MSG_READY;\n+\t\t\tadata.u.val = 0;\n+\t\t\tadata.size = sizeof(uint64_t);\n+\t\t\tbreak;\n+\t\tcase CNXK_REP_MSG_EXIT:\n+\t\t\tprocess_exit_message(msg_buf, buf_trav_len, msg->length, data);\n+\t\t\tadata.type = CNXK_REP_MSG_EXIT;\n+\t\t\tadata.u.val = 0;\n+\t\t\tadata.size = sizeof(uint64_t);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tplt_err(\"Invalid message type: %d\", msg->type);\n+\t\t\trc = -EINVAL;\n+\t\t};\n+\n+\t\t/* Send ACK */\n+\t\tif (send_ack)\n+\t\t\tsend_ack_message(&adata, mb_pool, portid);\n+\n+\t\t/* Advance to next message */\n+\t\tmsg = message_data_extract(msg_buf, buf_trav_len);\n+\t}\n+\n+\treturn 0;\n+fail:\n+\treturn rc;\n+}\n+\n+static int\n+process_control_packet(struct rte_mbuf *mbuf, void *data, uint16_t portid)\n+{\n+\tuint32_t len = mbuf->data_len;\n+\tuint32_t buf_trav_len = 0;\n+\tvoid *msg_buf;\n+\tint rc;\n+\n+\tmsg_buf = plt_zmalloc(len, 0);\n+\tif (!msg_buf) {\n+\t\tplt_err(\"Failed to allocate mem for msg_buf\");\n+\t\trc = -ENOMEM;\n+\t\tgoto fail;\n+\t}\n+\n+\t/* Extract the packet data which contains the message */\n+\trte_memcpy(msg_buf, rte_pktmbuf_mtod(mbuf, void *), len);\n+\n+\t/* Validate the validity of the received message */\n+\tparse_validate_header(msg_buf, &buf_trav_len);\n+\n+\t/* Detect message and process */\n+\trc = process_message(msg_buf, &buf_trav_len, data, mbuf->pool, portid);\n+\tif (rc) {\n+\t\tplt_err(\"Failed to process message\");\n+\t\tgoto fail;\n+\t}\n+\n+\t/* Ensuring entire message has been processed */\n+\tif (len != buf_trav_len) {\n+\t\tplt_err(\"Out of %d bytes %d bytes of msg_buf processed\", len, buf_trav_len);\n+\t\trc = -EFAULT;\n+\t\tgoto fail;\n+\t}\n+\n+\trte_free(msg_buf);\n+\n+\treturn 0;\n+fail:\n+\treturn rc;\n+}\n+\n+static int\n+receive_control_msg_resp(uint16_t portid, void *data)\n+{\n+\tuint32_t wait_us = CTRL_MSG_RCV_TIMEOUT_MS * 1000;\n+\tuint32_t timeout = 0, sleep = 1;\n+\tstruct rte_mbuf *m = NULL;\n+\tuint8_t rx = 0;\n+\tint rc = -1;\n+\n+\tdo {\n+\t\trx = rte_eth_rx_burst(portid, CNXK_REP_VDEV_CTRL_QUEUE, &m, 1);\n+\t\tif (rx != 0)\n+\t\t\tbreak;\n+\n+\t\t/* Timeout after CTRL_MSG_RCV_TIMEOUT_MS */\n+\t\tif (timeout >= wait_us) {\n+\t\t\tplt_err(\"Control message wait timedout\");\n+\t\t\treturn -ETIMEDOUT;\n+\t\t}\n+\n+\t\tplt_delay_us(sleep);\n+\t\ttimeout += sleep;\n+\t} while ((rx == 0) || (timeout < wait_us));\n+\n+\tif (rx) {\n+\t\trc = process_control_packet(m, data, portid);\n+\t\t/* Freeing the allocated buffer */\n+\t\trte_pktmbuf_free(m);\n+\t}\n+\n+\treturn rc;\n+}\n+\n+int\n+cnxk_rep_msg_send_process(struct cnxk_rep_dev *rep_dev, void *buffer, uint32_t len,\n+\t\t\t  cnxk_rep_msg_ack_data_t *adata)\n+{\n+\tstruct cnxk_eth_dev *pf_dev;\n+\tint rc = 0;\n+\n+\tpf_dev = cnxk_eth_pmd_priv(rep_dev->parent_dev);\n+\tif (!pf_dev) {\n+\t\tplt_err(\"Failed to get parent pf handle\");\n+\t\trc = -1;\n+\t\tgoto fail;\n+\t}\n+\n+\tplt_spinlock_lock(&pf_dev->rep_lock);\n+\trc = send_message(buffer, len, rep_dev->ctrl_chan_pool, rep_dev->rep_xport_vdev);\n+\tif (rc) {\n+\t\tplt_err(\"Failed to send the message, err %d\", rc);\n+\t\tgoto free;\n+\t}\n+\n+\trc = receive_control_msg_resp(rep_dev->rep_xport_vdev, adata);\n+\tif (rc) {\n+\t\tplt_err(\"Failed to receive the response, err %d\", rc);\n+\t\tgoto free;\n+\t}\n+\tplt_spinlock_unlock(&pf_dev->rep_lock);\n+\n+\treturn 0;\n+free:\n+\tplt_spinlock_unlock(&pf_dev->rep_lock);\n+fail:\n+\treturn rc;\n+}\n+\n+static void\n+poll_for_control_msg(void *data)\n+{\n+\tstruct cnxk_eth_dev *pf_dev = (struct cnxk_eth_dev *)data;\n+\tuint16_t portid = pf_dev->rep_xport_vdev;\n+\tstruct rte_mbuf *m = NULL;\n+\tuint8_t rx = 0;\n+\n+\tdo {\n+\t\trx = rte_eth_rx_burst(portid, CNXK_REP_VDEV_CTRL_QUEUE, &m, 1);\n+\t\tif (rx != 0)\n+\t\t\tbreak;\n+\t} while (rx == 0 && pf_dev->start_rep_thread);\n+\n+\tif (rx) {\n+\t\tplt_spinlock_lock(&pf_dev->rep_lock);\n+\t\tprocess_control_packet(m, data, portid);\n+\t\t/* Freeing the allocated buffer */\n+\t\trte_pktmbuf_free(m);\n+\t\tplt_spinlock_unlock(&pf_dev->rep_lock);\n+\t}\n+}\n+\n+static void *\n+rep_ctrl_msg_thread_main(void *arg)\n+{\n+\tstruct cnxk_eth_dev *pf_dev = (struct cnxk_eth_dev *)arg;\n+\n+\twhile (pf_dev->start_rep_thread)\n+\t\tpoll_for_control_msg(pf_dev);\n+\n+\treturn NULL;\n+}\n+\n+int\n+cnxk_rep_control_thread_launch(struct cnxk_eth_dev *pf_dev)\n+{\n+\tchar name[CTRL_MSG_THRD_NAME_LEN];\n+\tint rc = 0;\n+\n+\trte_strscpy(name, \"rep_ctrl_msg_hndlr\", CTRL_MSG_THRD_NAME_LEN);\n+\tpf_dev->start_rep_thread = true;\n+\trc = plt_ctrl_thread_create(&pf_dev->rep_ctrl_msg_thread, name, NULL,\n+\t\t\t\t    rep_ctrl_msg_thread_main, pf_dev);\n+\tif (rc != 0)\n+\t\tplt_err(\"Failed to create rep control message handling\");\n+\n+\treturn rc;\n+}\ndiff --git a/drivers/net/cnxk/cnxk_rep_msg.h b/drivers/net/cnxk/cnxk_rep_msg.h\nnew file mode 100644\nindex 0000000000..a28c63f762\n--- /dev/null\n+++ b/drivers/net/cnxk/cnxk_rep_msg.h\n@@ -0,0 +1,78 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2023 Marvell.\n+ */\n+\n+#ifndef __CNXK_REP_MSG_H__\n+#define __CNXK_REP_MSG_H__\n+\n+#include <stdint.h>\n+\n+#define CNXK_REP_MSG_MAX_BUFFER_SZ 1500\n+\n+typedef enum CNXK_TYPE {\n+\tCNXK_TYPE_HEADER = 0,\n+\tCNXK_TYPE_MSG,\n+} cnxk_type_t;\n+\n+typedef enum CNXK_REP_MSG {\n+\t/* General sync messages */\n+\tCNXK_REP_MSG_READY = 0,\n+\tCNXK_REP_MSG_ACK,\n+\tCNXK_REP_MSG_EXIT,\n+\t/* End of messaging sequence */\n+\tCNXK_REP_MSG_END,\n+} cnxk_rep_msg_t;\n+\n+/* Types */\n+typedef struct cnxk_type_data {\n+\tcnxk_type_t type;\n+\tuint32_t length;\n+\tuint64_t data[];\n+} __rte_packed cnxk_type_data_t;\n+\n+/* Header */\n+typedef struct cnxk_header {\n+\tuint64_t signature;\n+\tuint16_t nb_hops;\n+} __rte_packed cnxk_header_t;\n+\n+/* Message meta */\n+typedef struct cnxk_rep_msg_data {\n+\tcnxk_rep_msg_t type;\n+\tuint32_t length;\n+\tuint64_t data[];\n+} __rte_packed cnxk_rep_msg_data_t;\n+\n+/* Ack msg */\n+typedef struct cnxk_rep_msg_ack_data {\n+\tcnxk_rep_msg_t type;\n+\tuint32_t size;\n+\tunion {\n+\t\tvoid *data;\n+\t\tuint64_t val;\n+\t\tint64_t sval;\n+\t} u;\n+} __rte_packed cnxk_rep_msg_ack_data_t;\n+\n+/* Ready msg */\n+typedef struct cnxk_rep_msg_ready_data {\n+\tuint8_t val;\n+} __rte_packed cnxk_rep_msg_ready_data_t;\n+\n+/* Exit msg */\n+typedef struct cnxk_rep_msg_exit_data {\n+\tuint8_t val;\n+} __rte_packed cnxk_rep_msg_exit_data_t;\n+\n+void cnxk_rep_msg_populate_command(void *buffer, uint32_t *length, cnxk_rep_msg_t type,\n+\t\t\t\t   uint32_t size);\n+void cnxk_rep_msg_populate_command_meta(void *buffer, uint32_t *length, void *msg_meta, uint32_t sz,\n+\t\t\t\t\tcnxk_rep_msg_t msg);\n+void cnxk_rep_msg_populate_msg_end(void *buffer, uint32_t *length);\n+void cnxk_rep_msg_populate_type(void *buffer, uint32_t *length, cnxk_type_t type, uint32_t sz);\n+void cnxk_rep_msg_populate_header(void *buffer, uint32_t *length);\n+int cnxk_rep_msg_send_process(struct cnxk_rep_dev *rep_dev, void *buffer, uint32_t len,\n+\t\t\t      cnxk_rep_msg_ack_data_t *adata);\n+int cnxk_rep_control_thread_launch(struct cnxk_eth_dev *pf_dev);\n+\n+#endif /* __CNXK_REP_MSG_H__ */\ndiff --git a/drivers/net/cnxk/meson.build b/drivers/net/cnxk/meson.build\nindex 38dde54ce9..0e7334f5cd 100644\n--- a/drivers/net/cnxk/meson.build\n+++ b/drivers/net/cnxk/meson.build\n@@ -33,6 +33,7 @@ sources = files(\n         'cnxk_ptp.c',\n         'cnxk_flow.c',\n         'cnxk_rep.c',\n+        'cnxk_rep_msg.c',\n         'cnxk_rep_ops.c',\n         'cnxk_stats.c',\n         'cnxk_tm.c',\n",
    "prefixes": [
        "5/9"
    ]
}