get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 55444,
    "url": "http://patches.dpdk.org/api/patches/55444/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/39c7ced8ff87b4253c80ac90fe31bee445908c68.1561620219.git.xuanziyang2@huawei.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<39c7ced8ff87b4253c80ac90fe31bee445908c68.1561620219.git.xuanziyang2@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/39c7ced8ff87b4253c80ac90fe31bee445908c68.1561620219.git.xuanziyang2@huawei.com",
    "date": "2019-06-27T08:15:26",
    "name": "[v6,06/15] net/hinic/base: add mgmt module function code",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "74cfe78ba265a7c59ccbea46344ec87522201624",
    "submitter": {
        "id": 1321,
        "url": "http://patches.dpdk.org/api/people/1321/?format=api",
        "name": "Ziyang Xuan",
        "email": "xuanziyang2@huawei.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/39c7ced8ff87b4253c80ac90fe31bee445908c68.1561620219.git.xuanziyang2@huawei.com/mbox/",
    "series": [
        {
            "id": 5191,
            "url": "http://patches.dpdk.org/api/series/5191/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=5191",
            "date": "2019-06-27T08:10:12",
            "name": "A new net PMD - hinic",
            "version": 6,
            "mbox": "http://patches.dpdk.org/series/5191/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/55444/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/55444/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 F2A882BB5;\n\tThu, 27 Jun 2019 10:03:38 +0200 (CEST)",
            "from huawei.com (szxga04-in.huawei.com [45.249.212.190])\n\tby dpdk.org (Postfix) with ESMTP id 358852B98\n\tfor <dev@dpdk.org>; Thu, 27 Jun 2019 10:03:37 +0200 (CEST)",
            "from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58])\n\tby Forcepoint Email with ESMTP id CB062189904930D6A06D\n\tfor <dev@dpdk.org>; Thu, 27 Jun 2019 16:03:35 +0800 (CST)",
            "from tester_149.localdomain (10.175.119.39) by\n\tDGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP\n\tServer id 14.3.439.0; Thu, 27 Jun 2019 16:03:28 +0800"
        ],
        "From": "Ziyang Xuan <xuanziyang2@huawei.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<ferruh.yigit@intel.com>, <cloud.wangxiaoyun@huawei.com>,\n\t<shahar.belkar@huawei.com>, <luoxianjun@huawei.com>,\n\t<tanya.brokhman@huawei.com>, Ziyang Xuan <xuanziyang2@huawei.com>",
        "Date": "Thu, 27 Jun 2019 16:15:26 +0800",
        "Message-ID": "<39c7ced8ff87b4253c80ac90fe31bee445908c68.1561620219.git.xuanziyang2@huawei.com>",
        "X-Mailer": "git-send-email 2.18.0",
        "In-Reply-To": "<cover.1561620219.git.xuanziyang2@huawei.com>",
        "References": "<cover.1561620219.git.xuanziyang2@huawei.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.175.119.39]",
        "X-CFilter-Loop": "Reflected",
        "Subject": "[dpdk-dev] [PATCH v6 06/15] net/hinic/base: add mgmt module\n\tfunction code",
        "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": "Mgmt module is a kinkd of administration module for the chip.\nIt is responsible for handling administration command from host.\nIt uses api channel. This patch adds related data structures,\npackaged interfaces and function codes.\n\nSigned-off-by: Ziyang Xuan <xuanziyang2@huawei.com>\n---\n drivers/net/hinic/base/hinic_pmd_mgmt.c | 773 ++++++++++++++++++++++++\n drivers/net/hinic/base/hinic_pmd_mgmt.h | 119 ++++\n 2 files changed, 892 insertions(+)\n create mode 100644 drivers/net/hinic/base/hinic_pmd_mgmt.c\n create mode 100644 drivers/net/hinic/base/hinic_pmd_mgmt.h",
    "diff": "diff --git a/drivers/net/hinic/base/hinic_pmd_mgmt.c b/drivers/net/hinic/base/hinic_pmd_mgmt.c\nnew file mode 100644\nindex 000000000..bc18765ff\n--- /dev/null\n+++ b/drivers/net/hinic/base/hinic_pmd_mgmt.c\n@@ -0,0 +1,773 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2017 Huawei Technologies Co., Ltd\n+ */\n+\n+#include \"hinic_compat.h\"\n+#include \"hinic_csr.h\"\n+#include \"hinic_pmd_hwdev.h\"\n+#include \"hinic_pmd_hwif.h\"\n+#include \"hinic_pmd_mgmt.h\"\n+\n+#define BUF_OUT_DEFAULT_SIZE\t\t1\n+\n+#define MAX_PF_MGMT_BUF_SIZE\t\t2048UL\n+\n+#define MGMT_MSG_SIZE_MIN\t\t20\n+#define MGMT_MSG_SIZE_STEP\t\t16\n+#define\tMGMT_MSG_RSVD_FOR_DEV\t\t8\n+\n+#define MGMT_MSG_TIMEOUT\t\t5000\t/* millisecond */\n+\n+#define SYNC_MSG_ID_MASK\t\t0x1FF\n+#define ASYNC_MSG_ID_MASK\t\t0x1FF\n+#define ASYNC_MSG_FLAG\t\t\t0x200\n+\n+#define MSG_NO_RESP\t\t\t0xFFFF\n+\n+#define MAX_MSG_SZ\t\t\t2016\n+\n+#define MSG_SZ_IS_VALID(in_size)\t((in_size) <= MAX_MSG_SZ)\n+\n+#define SYNC_MSG_ID(pf_to_mgmt)\t\t((pf_to_mgmt)->sync_msg_id)\n+\n+#define SYNC_MSG_ID_INC(pf_to_mgmt)\t(SYNC_MSG_ID(pf_to_mgmt) = \\\n+\t\t\t(SYNC_MSG_ID(pf_to_mgmt) + 1) & SYNC_MSG_ID_MASK)\n+\n+#define ASYNC_MSG_ID(pf_to_mgmt)\t((pf_to_mgmt)->async_msg_id)\n+\n+#define ASYNC_MSG_ID_INC(pf_to_mgmt)\t(ASYNC_MSG_ID(pf_to_mgmt) = \\\n+\t\t\t((ASYNC_MSG_ID(pf_to_mgmt) + 1) & ASYNC_MSG_ID_MASK) \\\n+\t\t\t| ASYNC_MSG_FLAG)\n+\n+#define HINIC_SEQ_ID_MAX_VAL\t\t42\n+#define HINIC_MSG_SEG_LEN\t\t48\n+\n+#define GET_CURR_AEQ_ELEM(eq)\t\tGET_AEQ_ELEM((eq), (eq)->cons_idx)\n+\n+#define EQ_ELEM_DESC_TYPE_SHIFT\t\t\t0\n+#define EQ_ELEM_DESC_SRC_SHIFT\t\t\t7\n+#define EQ_ELEM_DESC_SIZE_SHIFT\t\t\t8\n+#define EQ_ELEM_DESC_WRAPPED_SHIFT\t\t31\n+\n+#define EQ_ELEM_DESC_TYPE_MASK\t\t\t0x7FU\n+#define EQ_ELEM_DESC_SRC_MASK\t\t\t0x1U\n+#define EQ_ELEM_DESC_SIZE_MASK\t\t\t0xFFU\n+#define EQ_ELEM_DESC_WRAPPED_MASK\t\t0x1U\n+\n+#define EQ_MSIX_RESEND_TIMER_CLEAR\t\t1\n+\n+#define EQ_ELEM_DESC_GET(val, member)\t\t\\\n+\t\t\t\t(((val) >> EQ_ELEM_DESC_##member##_SHIFT) & \\\n+\t\t\t\tEQ_ELEM_DESC_##member##_MASK)\n+\n+#define HINIC_MGMT_CHANNEL_STATUS_SHIFT\t\t0x0\n+#define HINIC_MGMT_CHANNEL_STATUS_MASK\t\t0x1\n+\n+#define HINIC_GET_MGMT_CHANNEL_STATUS(val, member)\t\\\n+\t(((val) >> HINIC_##member##_SHIFT) & HINIC_##member##_MASK)\n+\n+#define HINIC_MSG_TO_MGMT_MAX_LEN\t\t2016\n+\n+/**\n+ * mgmt_msg_len - calculate the total message length\n+ * @msg_data_len: the length of the message data\n+ * Return: the total message length\n+ **/\n+static u16 mgmt_msg_len(u16 msg_data_len)\n+{\n+\t/* u64 - the size of the header */\n+\tu16 msg_size = (u16)(MGMT_MSG_RSVD_FOR_DEV + sizeof(u64) +\n+\t\t\t     msg_data_len);\n+\n+\tif (msg_size > MGMT_MSG_SIZE_MIN)\n+\t\tmsg_size = MGMT_MSG_SIZE_MIN +\n+\t\t\tALIGN((msg_size - MGMT_MSG_SIZE_MIN),\n+\t\t\t      MGMT_MSG_SIZE_STEP);\n+\telse\n+\t\tmsg_size = MGMT_MSG_SIZE_MIN;\n+\n+\treturn msg_size;\n+}\n+\n+/**\n+ * prepare_header - prepare the header of the message\n+ * @pf_to_mgmt: PF to MGMT channel\n+ * @header: pointer of the header to prepare\n+ * @msg_len: the length of the message\n+ * @mod: module in the chip that will get the message\n+ * @ack_type: the type to response\n+ * @direction: the direction of the original message\n+ * @cmd: the command to do\n+ * @msg_id: message id\n+ **/\n+static void prepare_header(struct hinic_msg_pf_to_mgmt *pf_to_mgmt,\n+\t\t\t   u64 *header, int msg_len, enum hinic_mod_type mod,\n+\t\t\t   enum hinic_msg_ack_type ack_type,\n+\t\t\t   enum hinic_msg_direction_type direction,\n+\t\t\t   u8 cmd, u32 msg_id)\n+{\n+\tstruct hinic_hwif *hwif = pf_to_mgmt->hwdev->hwif;\n+\n+\t*header = HINIC_MSG_HEADER_SET(msg_len, MSG_LEN) |\n+\t\tHINIC_MSG_HEADER_SET(mod, MODULE) |\n+\t\tHINIC_MSG_HEADER_SET(msg_len, SEG_LEN) |\n+\t\tHINIC_MSG_HEADER_SET(ack_type, NO_ACK) |\n+\t\tHINIC_MSG_HEADER_SET(0, ASYNC_MGMT_TO_PF) |\n+\t\tHINIC_MSG_HEADER_SET(0, SEQID) |\n+\t\tHINIC_MSG_HEADER_SET(LAST_SEGMENT, LAST) |\n+\t\tHINIC_MSG_HEADER_SET(direction, DIRECTION) |\n+\t\tHINIC_MSG_HEADER_SET(cmd, CMD) |\n+\t\tHINIC_MSG_HEADER_SET(HINIC_PCI_INTF_IDX(hwif), PCI_INTF_IDX) |\n+\t\tHINIC_MSG_HEADER_SET(hwif->attr.port_to_port_idx, P2P_IDX) |\n+\t\tHINIC_MSG_HEADER_SET(msg_id, MSG_ID);\n+}\n+\n+/**\n+ * prepare_mgmt_cmd - prepare the mgmt command\n+ * @mgmt_cmd: pointer to the command to prepare\n+ * @header: pointer of the header to prepare\n+ * @msg: the data of the message\n+ * @msg_len: the length of the message\n+ **/\n+static void prepare_mgmt_cmd(u8 *mgmt_cmd, u64 *header, void *msg,\n+\t\t\t     int msg_len)\n+{\n+\tu32 cmd_buf_max = MAX_PF_MGMT_BUF_SIZE;\n+\n+\tmemset(mgmt_cmd, 0, MGMT_MSG_RSVD_FOR_DEV);\n+\n+\tmgmt_cmd += MGMT_MSG_RSVD_FOR_DEV;\n+\tcmd_buf_max -= MGMT_MSG_RSVD_FOR_DEV;\n+\tmemcpy(mgmt_cmd, header, sizeof(*header));\n+\n+\tmgmt_cmd += sizeof(*header);\n+\tcmd_buf_max -= sizeof(*header);\n+\tmemcpy(mgmt_cmd, msg, msg_len);\n+}\n+\n+/**\n+ * alloc_recv_msg - allocate received message memory\n+ * @recv_msg: pointer that will hold the allocated data\n+ * Return: 0 - success, negative - failure\n+ **/\n+static int alloc_recv_msg(struct hinic_recv_msg *recv_msg)\n+{\n+\tint err;\n+\n+\trecv_msg->msg = kzalloc(MAX_PF_MGMT_BUF_SIZE, GFP_KERNEL);\n+\tif (!recv_msg->msg) {\n+\t\tPMD_DRV_LOG(ERR, \"Allocate recv msg buf failed\");\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\trecv_msg->buf_out = kzalloc(MAX_PF_MGMT_BUF_SIZE, GFP_KERNEL);\n+\tif (!recv_msg->buf_out) {\n+\t\tPMD_DRV_LOG(ERR, \"Allocate recv msg output buf failed\");\n+\t\terr = -ENOMEM;\n+\t\tgoto alloc_buf_out_err;\n+\t}\n+\n+\treturn 0;\n+\n+alloc_buf_out_err:\n+\tkfree(recv_msg->msg);\n+\treturn err;\n+}\n+\n+/**\n+ * free_recv_msg - free received message memory\n+ * @recv_msg: pointer that holds the allocated data\n+ **/\n+static void free_recv_msg(struct hinic_recv_msg *recv_msg)\n+{\n+\tkfree(recv_msg->buf_out);\n+\tkfree(recv_msg->msg);\n+}\n+\n+/**\n+ * alloc_msg_buf - allocate all the message buffers of PF to MGMT channel\n+ * @pf_to_mgmt: PF to MGMT channel\n+ * Return: 0 - success, negative - failure\n+ **/\n+static int alloc_msg_buf(struct hinic_msg_pf_to_mgmt *pf_to_mgmt)\n+{\n+\tint err;\n+\n+\terr = alloc_recv_msg(&pf_to_mgmt->recv_msg_from_mgmt);\n+\tif (err) {\n+\t\tPMD_DRV_LOG(ERR, \"Allocate recv msg failed\");\n+\t\treturn err;\n+\t}\n+\n+\terr = alloc_recv_msg(&pf_to_mgmt->recv_resp_msg_from_mgmt);\n+\tif (err) {\n+\t\tPMD_DRV_LOG(ERR, \"Allocate resp recv msg failed\");\n+\t\tgoto alloc_msg_for_resp_err;\n+\t}\n+\n+\tpf_to_mgmt->async_msg_buf = kzalloc(MAX_PF_MGMT_BUF_SIZE, GFP_KERNEL);\n+\tif (!pf_to_mgmt->async_msg_buf)\t{\n+\t\tPMD_DRV_LOG(ERR, \"Allocate async msg buf failed\");\n+\t\terr = -ENOMEM;\n+\t\tgoto async_msg_buf_err;\n+\t}\n+\n+\tpf_to_mgmt->sync_msg_buf = kzalloc(MAX_PF_MGMT_BUF_SIZE, GFP_KERNEL);\n+\tif (!pf_to_mgmt->sync_msg_buf)\t{\n+\t\tPMD_DRV_LOG(ERR, \"Allocate sync msg buf failed\");\n+\t\terr = -ENOMEM;\n+\t\tgoto sync_msg_buf_err;\n+\t}\n+\n+\treturn 0;\n+\n+sync_msg_buf_err:\n+\tkfree(pf_to_mgmt->async_msg_buf);\n+\n+async_msg_buf_err:\n+\tfree_recv_msg(&pf_to_mgmt->recv_resp_msg_from_mgmt);\n+\n+alloc_msg_for_resp_err:\n+\tfree_recv_msg(&pf_to_mgmt->recv_msg_from_mgmt);\n+\n+\treturn err;\n+}\n+\n+/**\n+ * free_msg_buf - free all the message buffers of PF to MGMT channel\n+ * @pf_to_mgmt: PF to MGMT channel\n+ * Return: 0 - success, negative - failure\n+ **/\n+static void free_msg_buf(struct hinic_msg_pf_to_mgmt *pf_to_mgmt)\n+{\n+\tkfree(pf_to_mgmt->sync_msg_buf);\n+\tkfree(pf_to_mgmt->async_msg_buf);\n+\n+\tfree_recv_msg(&pf_to_mgmt->recv_resp_msg_from_mgmt);\n+\tfree_recv_msg(&pf_to_mgmt->recv_msg_from_mgmt);\n+}\n+\n+/**\n+ * send_msg_to_mgmt_async - send async message\n+ * @pf_to_mgmt: PF to MGMT channel\n+ * @mod: module in the chip that will get the message\n+ * @cmd: command of the message\n+ * @msg: the data of the message\n+ * @msg_len: the length of the message\n+ * @direction: the direction of the original message\n+ * @resp_msg_id: message id of response\n+ * Return: 0 - success, negative - failure\n+ **/\n+static int send_msg_to_mgmt_async(struct hinic_msg_pf_to_mgmt *pf_to_mgmt,\n+\t\t\t\t  enum hinic_mod_type mod, u8 cmd,\n+\t\t\t\t  void *msg, u16 msg_len,\n+\t\t\t\t  enum hinic_msg_direction_type direction,\n+\t\t\t\t  u16 resp_msg_id)\n+{\n+\tvoid *mgmt_cmd = pf_to_mgmt->async_msg_buf;\n+\tstruct hinic_api_cmd_chain *chain;\n+\tu64 header;\n+\tu16 cmd_size = mgmt_msg_len(msg_len);\n+\n+\tif (direction == HINIC_MSG_RESPONSE)\n+\t\tprepare_header(pf_to_mgmt, &header, msg_len, mod, HINIC_MSG_ACK,\n+\t\t\t       direction, cmd, resp_msg_id);\n+\telse\n+\t\tprepare_header(pf_to_mgmt, &header, msg_len, mod, HINIC_MSG_ACK,\n+\t\t\t       direction, cmd, ASYNC_MSG_ID(pf_to_mgmt));\n+\n+\tprepare_mgmt_cmd((u8 *)mgmt_cmd, &header, msg, msg_len);\n+\n+\tchain = pf_to_mgmt->cmd_chain[HINIC_API_CMD_WRITE_ASYNC_TO_MGMT_CPU];\n+\n+\treturn hinic_api_cmd_write(chain, HINIC_NODE_ID_MGMT_HOST, mgmt_cmd,\n+\t\t\t\t   cmd_size);\n+}\n+\n+/**\n+ * send_msg_to_mgmt_sync - send async message\n+ * @pf_to_mgmt: PF to MGMT channel\n+ * @mod: module in the chip that will get the message\n+ * @cmd: command of the message\n+ * @msg: the msg data\n+ * @msg_len: the msg data length\n+ * @ack_type: indicate mgmt command whether need ack or not\n+ * @direction: the direction of the original message\n+ * @resp_msg_id: msg id to response for\n+ * Return: 0 - success, negative - failure\n+ **/\n+static int send_msg_to_mgmt_sync(struct hinic_msg_pf_to_mgmt *pf_to_mgmt,\n+\t\t\t\t enum hinic_mod_type mod, u8 cmd,\n+\t\t\t\t void *msg, u16 msg_len,\n+\t\t\t\t enum hinic_msg_ack_type ack_type,\n+\t\t\t\t enum hinic_msg_direction_type direction,\n+\t\t\t\t __rte_unused u16 resp_msg_id)\n+{\n+\tvoid *mgmt_cmd = pf_to_mgmt->sync_msg_buf;\n+\tstruct hinic_api_cmd_chain *chain;\n+\tu64 header;\n+\tu16 cmd_size = mgmt_msg_len(msg_len);\n+\n+\tif (direction == HINIC_MSG_RESPONSE)\n+\t\tprepare_header(pf_to_mgmt, &header, msg_len, mod, ack_type,\n+\t\t\t       direction, cmd, resp_msg_id);\n+\telse\n+\t\tprepare_header(pf_to_mgmt, &header, msg_len, mod, ack_type,\n+\t\t\t       direction, cmd, SYNC_MSG_ID(pf_to_mgmt));\n+\n+\tprepare_mgmt_cmd((u8 *)mgmt_cmd, &header, msg, msg_len);\n+\n+\tchain = pf_to_mgmt->cmd_chain[HINIC_API_CMD_PMD_WRITE_TO_MGMT];\n+\n+\treturn hinic_api_cmd_write(chain, HINIC_NODE_ID_MGMT_HOST,\n+\t\t\t\t   mgmt_cmd, cmd_size);\n+}\n+\n+/**\n+ * hinic_pf_to_mgmt_init - initialize PF to MGMT channel\n+ * @hwdev: the pointer to the private hardware device object\n+ * Return: 0 - success, negative - failure\n+ **/\n+static int hinic_pf_to_mgmt_init(struct hinic_hwdev *hwdev)\n+{\n+\tstruct hinic_msg_pf_to_mgmt *pf_to_mgmt;\n+\tint err;\n+\n+\tpf_to_mgmt = kzalloc(sizeof(*pf_to_mgmt), GFP_KERNEL);\n+\tif (!pf_to_mgmt) {\n+\t\tPMD_DRV_LOG(ERR, \"Allocate pf to mgmt mem failed\");\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\thwdev->pf_to_mgmt = pf_to_mgmt;\n+\tpf_to_mgmt->hwdev = hwdev;\n+\n+\tspin_lock_init(&pf_to_mgmt->async_msg_lock);\n+\tspin_lock_init(&pf_to_mgmt->sync_msg_lock);\n+\n+\terr = alloc_msg_buf(pf_to_mgmt);\n+\tif (err) {\n+\t\tPMD_DRV_LOG(ERR, \"Allocate msg buffers failed\");\n+\t\tgoto alloc_msg_buf_err;\n+\t}\n+\n+\terr = hinic_api_cmd_init(hwdev, pf_to_mgmt->cmd_chain);\n+\tif (err) {\n+\t\tPMD_DRV_LOG(ERR, \"Init the api cmd chains failed\");\n+\t\tgoto api_cmd_init_err;\n+\t}\n+\n+\treturn 0;\n+\n+api_cmd_init_err:\n+\tfree_msg_buf(pf_to_mgmt);\n+\n+alloc_msg_buf_err:\n+\tkfree(pf_to_mgmt);\n+\n+\treturn err;\n+}\n+\n+/**\n+ * hinic_pf_to_mgmt_free - free PF to MGMT channel\n+ * @hwdev: the pointer to the private hardware device object\n+ **/\n+static void hinic_pf_to_mgmt_free(struct hinic_hwdev *hwdev)\n+{\n+\tstruct hinic_msg_pf_to_mgmt *pf_to_mgmt = hwdev->pf_to_mgmt;\n+\n+\thinic_api_cmd_free(pf_to_mgmt->cmd_chain);\n+\tfree_msg_buf(pf_to_mgmt);\n+\tkfree(pf_to_mgmt);\n+}\n+\n+static int\n+hinic_pf_to_mgmt_sync(struct hinic_hwdev *hwdev,\n+\t\tenum hinic_mod_type mod, u8 cmd, void *buf_in, u16 in_size,\n+\t\tvoid *buf_out, u16 *out_size, u32 timeout)\n+{\n+\tstruct hinic_msg_pf_to_mgmt *pf_to_mgmt = hwdev->pf_to_mgmt;\n+\tstruct hinic_recv_msg *recv_msg;\n+\tu32 timeo;\n+\tint err, i;\n+\n+\tspin_lock(&pf_to_mgmt->sync_msg_lock);\n+\n+\tSYNC_MSG_ID_INC(pf_to_mgmt);\n+\trecv_msg = &pf_to_mgmt->recv_resp_msg_from_mgmt;\n+\n+\terr = send_msg_to_mgmt_sync(pf_to_mgmt, mod, cmd, buf_in, in_size,\n+\t\t\t\t    HINIC_MSG_ACK, HINIC_MSG_DIRECT_SEND,\n+\t\t\t\t    MSG_NO_RESP);\n+\tif (err) {\n+\t\tPMD_DRV_LOG(ERR, \"Send msg to mgmt failed\");\n+\t\tgoto unlock_sync_msg;\n+\t}\n+\n+\ttimeo = msecs_to_jiffies(timeout ? timeout : MGMT_MSG_TIMEOUT);\n+\tfor (i = 0; i < pf_to_mgmt->rx_aeq->poll_retry_nr; i++) {\n+\t\terr = hinic_aeq_poll_msg(pf_to_mgmt->rx_aeq, timeo, NULL);\n+\t\tif (err) {\n+\t\t\tPMD_DRV_LOG(ERR, \"Poll mgmt rsp timeout, mod=%d cmd=%d msg_id=%u rc=%d\",\n+\t\t\t\tmod, cmd, pf_to_mgmt->sync_msg_id, err);\n+\t\t\terr = -ETIMEDOUT;\n+\t\t\thinic_dump_aeq_info(hwdev);\n+\t\t\tgoto unlock_sync_msg;\n+\t\t} else {\n+\t\t\tif (mod == recv_msg->mod && cmd == recv_msg->cmd &&\n+\t\t\t    recv_msg->msg_id == pf_to_mgmt->sync_msg_id) {\n+\t\t\t\t/* the expected response polled */\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tPMD_DRV_LOG(ERR, \"AEQ[%d] poll(mod=%d, cmd=%d, msg_id=%u) an \"\n+\t\t\t\t\"unexpected(mod=%d, cmd=%d, msg_id=%u) response\",\n+\t\t\t\tpf_to_mgmt->rx_aeq->q_id, mod, cmd,\n+\t\t\t\tpf_to_mgmt->sync_msg_id, recv_msg->mod,\n+\t\t\t\trecv_msg->cmd, recv_msg->msg_id);\n+\t\t}\n+\t}\n+\n+\tif (i == pf_to_mgmt->rx_aeq->poll_retry_nr) {\n+\t\tPMD_DRV_LOG(ERR, \"Get %d unexpected mgmt rsp from AEQ[%d], poll mgmt rsp failed\",\n+\t\t\ti, pf_to_mgmt->rx_aeq->q_id);\n+\t\terr = -EBADMSG;\n+\t\tgoto unlock_sync_msg;\n+\t}\n+\n+\trte_smp_rmb();\n+\tif (recv_msg->msg_len && buf_out && out_size) {\n+\t\tif (recv_msg->msg_len <= *out_size) {\n+\t\t\tmemcpy(buf_out, recv_msg->msg,\n+\t\t\t       recv_msg->msg_len);\n+\t\t\t*out_size = recv_msg->msg_len;\n+\t\t} else {\n+\t\t\tPMD_DRV_LOG(ERR, \"Mgmt rsp's msg len:%u overflow.\",\n+\t\t\t\trecv_msg->msg_len);\n+\t\t\terr = -ERANGE;\n+\t\t}\n+\t}\n+\n+unlock_sync_msg:\n+\tif (err && out_size)\n+\t\t*out_size = 0;\n+\tspin_unlock(&pf_to_mgmt->sync_msg_lock);\n+\treturn err;\n+}\n+\n+static int hinic_get_mgmt_channel_status(void *hwdev)\n+{\n+\tstruct hinic_hwif *hwif = ((struct hinic_hwdev *)hwdev)->hwif;\n+\tu32 val;\n+\n+\tval = hinic_hwif_read_reg(hwif, HINIC_ICPL_RESERVD_ADDR);\n+\n+\treturn HINIC_GET_MGMT_CHANNEL_STATUS(val, MGMT_CHANNEL_STATUS);\n+}\n+\n+int hinic_msg_to_mgmt_sync(void *hwdev, enum hinic_mod_type mod, u8 cmd,\n+\t\t\t   void *buf_in, u16 in_size,\n+\t\t\t   void *buf_out, u16 *out_size, u32 timeout)\n+{\n+\tint rc = HINIC_ERROR;\n+\n+\tif (!hwdev || in_size > HINIC_MSG_TO_MGMT_MAX_LEN)\n+\t\treturn -EINVAL;\n+\n+\t/* If status is hot upgrading, don't send message to mgmt */\n+\tif (hinic_get_mgmt_channel_status(hwdev))\n+\t\treturn -EPERM;\n+\n+\trc = hinic_pf_to_mgmt_sync(hwdev, mod, cmd, buf_in,\n+\t\t\t\t   in_size, buf_out, out_size,\n+\t\t\t\t   timeout);\n+\n+\treturn rc;\n+}\n+\n+int hinic_msg_to_mgmt_no_ack(void *hwdev, enum hinic_mod_type mod, u8 cmd,\n+\t\t     void *buf_in, u16 in_size, __rte_unused void *buf_out,\n+\t\t     __rte_unused u16 *out_size)\n+{\n+\tstruct hinic_msg_pf_to_mgmt *pf_to_mgmt =\n+\t\t\t\t((struct hinic_hwdev *)hwdev)->pf_to_mgmt;\n+\tint err = -EINVAL;\n+\n+\tif (!MSG_SZ_IS_VALID(in_size)) {\n+\t\tPMD_DRV_LOG(ERR, \"Mgmt msg buffer size is invalid\");\n+\t\treturn err;\n+\t}\n+\n+\tspin_lock(&pf_to_mgmt->sync_msg_lock);\n+\n+\terr = send_msg_to_mgmt_sync(pf_to_mgmt, mod, cmd, buf_in, in_size,\n+\t\t\t\t    HINIC_MSG_NO_ACK, HINIC_MSG_DIRECT_SEND,\n+\t\t\t\t    MSG_NO_RESP);\n+\n+\tspin_unlock(&pf_to_mgmt->sync_msg_lock);\n+\n+\treturn err;\n+}\n+\n+static bool check_mgmt_seq_id_and_seg_len(struct hinic_recv_msg *recv_msg,\n+\t\t\t\t\t  u8 seq_id, u8 seg_len)\n+{\n+\tif (seq_id > HINIC_SEQ_ID_MAX_VAL || seg_len > HINIC_MSG_SEG_LEN)\n+\t\treturn false;\n+\n+\tif (seq_id == 0) {\n+\t\trecv_msg->sed_id = seq_id;\n+\t} else {\n+\t\tif (seq_id != recv_msg->sed_id + 1) {\n+\t\t\trecv_msg->sed_id = 0;\n+\t\t\treturn false;\n+\t\t}\n+\t\trecv_msg->sed_id = seq_id;\n+\t}\n+\n+\treturn true;\n+}\n+\n+/**\n+ * hinic_mgmt_recv_msg_handler - handler for message from mgmt cpu\n+ * @pf_to_mgmt: PF to MGMT channel\n+ * @recv_msg: received message details\n+ * @param: customized parameter\n+ **/\n+static void hinic_mgmt_recv_msg_handler(struct hinic_msg_pf_to_mgmt *pf_to_mgmt,\n+\t\t\t\t\tstruct hinic_recv_msg *recv_msg,\n+\t\t\t\t\tvoid *param)\n+{\n+\tvoid *buf_out = recv_msg->buf_out;\n+\tu16 out_size = 0;\n+\n+\tswitch (recv_msg->mod) {\n+\tcase HINIC_MOD_COMM:\n+\t\thinic_comm_async_event_handle(pf_to_mgmt->hwdev,\n+\t\t\t\t\t      recv_msg->cmd, recv_msg->msg,\n+\t\t\t\t\t      recv_msg->msg_len,\n+\t\t\t\t\t      buf_out, &out_size);\n+\t\tbreak;\n+\tcase HINIC_MOD_L2NIC:\n+\t\thinic_l2nic_async_event_handle(pf_to_mgmt->hwdev, param,\n+\t\t\t\t\t       recv_msg->cmd, recv_msg->msg,\n+\t\t\t\t\t       recv_msg->msg_len,\n+\t\t\t\t\t       buf_out, &out_size);\n+\t\tbreak;\n+\tcase HINIC_MOD_HILINK:\n+\t\thinic_hilink_async_event_handle(pf_to_mgmt->hwdev,\n+\t\t\t\t\t\trecv_msg->cmd, recv_msg->msg,\n+\t\t\t\t\t\trecv_msg->msg_len,\n+\t\t\t\t\t\tbuf_out, &out_size);\n+\t\tbreak;\n+\tdefault:\n+\t\tPMD_DRV_LOG(ERR, \"No handler, mod = %d\", recv_msg->mod);\n+\t\tbreak;\n+\t}\n+\n+\tif (!recv_msg->async_mgmt_to_pf) {\n+\t\tif (!out_size)\n+\t\t\tout_size = BUF_OUT_DEFAULT_SIZE;\n+\n+\t\t/* MGMT sent sync msg, send the response */\n+\t\t(void)send_msg_to_mgmt_async(pf_to_mgmt, recv_msg->mod,\n+\t\t\t\t\t     recv_msg->cmd, buf_out, out_size,\n+\t\t\t\t\t     HINIC_MSG_RESPONSE,\n+\t\t\t\t\t     recv_msg->msg_id);\n+\t}\n+}\n+\n+/**\n+ * recv_mgmt_msg_handler - handler a message from mgmt cpu\n+ * @pf_to_mgmt: PF to MGMT channel\n+ * @header: the header of the message\n+ * @recv_msg: received message details\n+ * @param: customized parameter\n+ * Return: 0 when aeq is response message, -1 default result,\n+ * and when wrong message or not last message\n+ **/\n+static int recv_mgmt_msg_handler(struct hinic_msg_pf_to_mgmt *pf_to_mgmt,\n+\t\t\t\t u8 *header, struct hinic_recv_msg *recv_msg,\n+\t\t\t\t void *param)\n+{\n+\tu64 msg_header = *((u64 *)header);\n+\tvoid *msg_body = header + sizeof(msg_header);\n+\tu8 *dest_msg;\n+\tu8 seq_id, seq_len;\n+\tu32 msg_buf_max = MAX_PF_MGMT_BUF_SIZE;\n+\n+\tseq_id = HINIC_MSG_HEADER_GET(msg_header, SEQID);\n+\tseq_len = HINIC_MSG_HEADER_GET(msg_header, SEG_LEN);\n+\n+\tif (!check_mgmt_seq_id_and_seg_len(recv_msg, seq_id, seq_len)) {\n+\t\tPMD_DRV_LOG(ERR,\n+\t\t\t\"Mgmt msg sequence and segment check fail, \"\n+\t\t\t\"func id: 0x%x, front id: 0x%x, current id: 0x%x, seg len: 0x%x\",\n+\t\t\thinic_global_func_id(pf_to_mgmt->hwdev),\n+\t\t\trecv_msg->sed_id, seq_id, seq_len);\n+\t\treturn HINIC_RECV_NEXT_AEQE;\n+\t}\n+\n+\tdest_msg = (u8 *)recv_msg->msg + seq_id * HINIC_MSG_SEG_LEN;\n+\tmsg_buf_max -= seq_id * HINIC_MSG_SEG_LEN;\n+\tmemcpy(dest_msg, msg_body, seq_len);\n+\n+\tif (!HINIC_MSG_HEADER_GET(msg_header, LAST))\n+\t\treturn HINIC_RECV_NEXT_AEQE;\n+\n+\trecv_msg->cmd = HINIC_MSG_HEADER_GET(msg_header, CMD);\n+\trecv_msg->mod = HINIC_MSG_HEADER_GET(msg_header, MODULE);\n+\trecv_msg->async_mgmt_to_pf = HINIC_MSG_HEADER_GET(msg_header,\n+\t\t\t\t\t\t\t  ASYNC_MGMT_TO_PF);\n+\trecv_msg->msg_len = HINIC_MSG_HEADER_GET(msg_header, MSG_LEN);\n+\trecv_msg->msg_id = HINIC_MSG_HEADER_GET(msg_header, MSG_ID);\n+\n+\tif (HINIC_MSG_HEADER_GET(msg_header, DIRECTION) == HINIC_MSG_RESPONSE)\n+\t\treturn HINIC_RECV_DONE;\n+\n+\thinic_mgmt_recv_msg_handler(pf_to_mgmt, recv_msg, param);\n+\n+\treturn HINIC_RECV_NEXT_AEQE;\n+}\n+\n+/**\n+ * hinic_mgmt_msg_aeqe_handler - handler for a mgmt message event\n+ * @hwdev: the pointer to the private hardware device object\n+ * @header: the header of the message\n+ * @size: unused\n+ * @param: customized parameter\n+ * Return: 0 when aeq is response message,\n+ *\t   -1 default result, and when wrong message or not last message\n+ **/\n+static int hinic_mgmt_msg_aeqe_handler(void *hwdev, u8 *header,\n+\t\t\t__rte_unused u8 size, void *param)\n+{\n+\tstruct hinic_msg_pf_to_mgmt *pf_to_mgmt =\n+\t\t\t\t((struct hinic_hwdev *)hwdev)->pf_to_mgmt;\n+\tstruct hinic_recv_msg *recv_msg;\n+\n+\trecv_msg = (HINIC_MSG_HEADER_GET(*(u64 *)header, DIRECTION) ==\n+\t\t    HINIC_MSG_DIRECT_SEND) ?\n+\t\t    &pf_to_mgmt->recv_msg_from_mgmt :\n+\t\t    &pf_to_mgmt->recv_resp_msg_from_mgmt;\n+\n+\treturn recv_mgmt_msg_handler(pf_to_mgmt, header, recv_msg, param);\n+}\n+\n+static int hinic_handle_aeqe(void *handle, enum hinic_aeq_type event,\n+\t\t      u8 *data, u8 size, void *param)\n+{\n+\tint rc = 0;\n+\n+\tswitch (event) {\n+\tcase HINIC_MSG_FROM_MGMT_CPU:\n+\t\trc = hinic_mgmt_msg_aeqe_handler(handle, data, size, param);\n+\t\tbreak;\n+\tdefault:\n+\t\tPMD_DRV_LOG(ERR, \"Unknown event type: 0x%x, size: %d\",\n+\t\t\t    event, size);\n+\t\trc = HINIC_RECV_NEXT_AEQE;\n+\t\tbreak;\n+\t}\n+\n+\treturn rc;\n+}\n+\n+/**\n+ * hinic_aeq_poll_msg - poll one or continue aeqe, and call dedicated process\n+ * @eq: aeq of the chip\n+ * @timeout: 0   - poll all aeqe in eq, used in interrupt mode,\n+ *           > 0 - poll aeq until get aeqe with 'last' field set to 1,\n+ *           used in polling mode.\n+ * @param: customized parameter\n+ * Return: 0 - Success, EIO - poll timeout, ENODEV - swe not support\n+ **/\n+int hinic_aeq_poll_msg(struct hinic_eq *eq, u32 timeout, void *param)\n+{\n+\tstruct hinic_aeq_elem *aeqe_pos;\n+\tenum hinic_aeq_type event;\n+\tu32 aeqe_desc = 0;\n+\tu16 i;\n+\tu8 size;\n+\tint done = HINIC_ERROR;\n+\tint err = -EFAULT;\n+\tunsigned long end;\n+\n+\tfor (i = 0; ((timeout == 0) && (i < eq->eq_len)) ||\n+\t     ((timeout > 0) && (done != HINIC_OK) && (i < eq->eq_len)); i++) {\n+\t\terr = -EIO;\n+\t\tend = jiffies + msecs_to_jiffies(timeout);\n+\t\tdo {\n+\t\t\taeqe_pos = GET_CURR_AEQ_ELEM(eq);\n+\t\t\trte_rmb();\n+\n+\t\t\t/* Data in HW is in Big endian Format */\n+\t\t\taeqe_desc = be32_to_cpu(aeqe_pos->desc);\n+\n+\t\t\t/* HW updates wrapped bit,\n+\t\t\t * when it adds eq element event\n+\t\t\t */\n+\t\t\tif (EQ_ELEM_DESC_GET(aeqe_desc, WRAPPED)\n+\t\t\t    != eq->wrapped) {\n+\t\t\t\terr = 0;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\n+\t\t\tif (timeout != 0)\n+\t\t\t\trte_delay_ms(1);\n+\t\t} while (time_before(jiffies, end));\n+\n+\t\tif (err != HINIC_OK) /*poll time out*/\n+\t\t\tbreak;\n+\n+\t\tevent = EQ_ELEM_DESC_GET(aeqe_desc, TYPE);\n+\t\tif (EQ_ELEM_DESC_GET(aeqe_desc, SRC)) {\n+\t\t\tPMD_DRV_LOG(ERR, \"AEQ sw event not support %d\",\n+\t\t\t\tevent);\n+\t\t\treturn -ENODEV;\n+\n+\t\t} else {\n+\t\t\tsize = EQ_ELEM_DESC_GET(aeqe_desc, SIZE);\n+\t\t\tdone = hinic_handle_aeqe(eq->hwdev, event,\n+\t\t\t\t\t\t aeqe_pos->aeqe_data,\n+\t\t\t\t\t\t size, param);\n+\t\t}\n+\n+\t\teq->cons_idx++;\n+\t\tif (eq->cons_idx == eq->eq_len) {\n+\t\t\teq->cons_idx = 0;\n+\t\t\teq->wrapped = !eq->wrapped;\n+\t\t}\n+\t}\n+\n+\teq_update_ci(eq);\n+\n+\treturn err;\n+}\n+\n+int hinic_comm_pf_to_mgmt_init(struct hinic_hwdev *hwdev)\n+{\n+\tint rc;\n+\n+\trc = hinic_pf_to_mgmt_init(hwdev);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\thwdev->pf_to_mgmt->rx_aeq = &hwdev->aeqs->aeq[HINIC_MGMT_RSP_AEQN];\n+\n+\treturn 0;\n+}\n+\n+void hinic_comm_pf_to_mgmt_free(struct hinic_hwdev *hwdev)\n+{\n+\thinic_pf_to_mgmt_free(hwdev);\n+}\n+\n+void hinic_dev_handle_aeq_event(struct hinic_hwdev *hwdev, void *param)\n+{\n+\tstruct hinic_eq *aeq = &hwdev->aeqs->aeq[0];\n+\n+\t/* clear resend timer cnt register */\n+\thinic_misx_intr_clear_resend_bit(hwdev, aeq->eq_irq.msix_entry_idx,\n+\t\t\t\t\t EQ_MSIX_RESEND_TIMER_CLEAR);\n+\t(void)hinic_aeq_poll_msg(aeq, 0, param);\n+}\ndiff --git a/drivers/net/hinic/base/hinic_pmd_mgmt.h b/drivers/net/hinic/base/hinic_pmd_mgmt.h\nnew file mode 100644\nindex 000000000..23951cb7e\n--- /dev/null\n+++ b/drivers/net/hinic/base/hinic_pmd_mgmt.h\n@@ -0,0 +1,119 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2017 Huawei Technologies Co., Ltd\n+ */\n+\n+#ifndef _HINIC_PMD_MGMT_H_\n+#define _HINIC_PMD_MGMT_H_\n+\n+#include \"hinic_pmd_api_cmd.h\"\n+#include \"hinic_pmd_eqs.h\"\n+\n+#define HINIC_MSG_HEADER_MSG_LEN_SHIFT\t\t\t\t0\n+#define HINIC_MSG_HEADER_MODULE_SHIFT\t\t\t\t11\n+#define HINIC_MSG_HEADER_SEG_LEN_SHIFT\t\t\t\t16\n+#define HINIC_MSG_HEADER_NO_ACK_SHIFT\t\t\t\t22\n+#define HINIC_MSG_HEADER_ASYNC_MGMT_TO_PF_SHIFT\t\t\t23\n+#define HINIC_MSG_HEADER_SEQID_SHIFT\t\t\t\t24\n+#define HINIC_MSG_HEADER_LAST_SHIFT\t\t\t\t30\n+#define HINIC_MSG_HEADER_DIRECTION_SHIFT\t\t\t31\n+#define HINIC_MSG_HEADER_CMD_SHIFT\t\t\t\t32\n+#define HINIC_MSG_HEADER_PCI_INTF_IDX_SHIFT\t\t\t48\n+#define HINIC_MSG_HEADER_P2P_IDX_SHIFT\t\t\t\t50\n+#define HINIC_MSG_HEADER_MSG_ID_SHIFT\t\t\t\t54\n+\n+#define HINIC_MSG_HEADER_MSG_LEN_MASK\t\t\t\t0x7FF\n+#define HINIC_MSG_HEADER_MODULE_MASK\t\t\t\t0x1F\n+#define HINIC_MSG_HEADER_SEG_LEN_MASK\t\t\t\t0x3F\n+#define HINIC_MSG_HEADER_NO_ACK_MASK\t\t\t\t0x1\n+#define HINIC_MSG_HEADER_ASYNC_MGMT_TO_PF_MASK\t\t\t0x1\n+#define HINIC_MSG_HEADER_SEQID_MASK\t\t\t\t0x3F\n+#define HINIC_MSG_HEADER_LAST_MASK\t\t\t\t0x1\n+#define HINIC_MSG_HEADER_DIRECTION_MASK\t\t\t\t0x1\n+#define HINIC_MSG_HEADER_CMD_MASK\t\t\t\t0xFF\n+#define HINIC_MSG_HEADER_PCI_INTF_IDX_MASK\t\t\t0x3\n+#define HINIC_MSG_HEADER_P2P_IDX_MASK\t\t\t\t0xF\n+#define HINIC_MSG_HEADER_MSG_ID_MASK\t\t\t\t0x3FF\n+\n+#define HINIC_MSG_HEADER_GET(val, member)\t\t\t\\\n+\t\t(((val) >> HINIC_MSG_HEADER_##member##_SHIFT) & \\\n+\t\tHINIC_MSG_HEADER_##member##_MASK)\n+\n+#define HINIC_MSG_HEADER_SET(val, member)\t\t\t\\\n+\t\t((u64)((val) & HINIC_MSG_HEADER_##member##_MASK) << \\\n+\t\tHINIC_MSG_HEADER_##member##_SHIFT)\n+\n+#define HINIC_MGMT_RSP_AEQN\t\t(1)\n+\n+enum hinic_msg_direction_type {\n+\tHINIC_MSG_DIRECT_SEND\t= 0,\n+\tHINIC_MSG_RESPONSE\t= 1\n+};\n+enum hinic_msg_segment_type {\n+\tNOT_LAST_SEGMENT = 0,\n+\tLAST_SEGMENT\t= 1,\n+};\n+\n+enum hinic_msg_ack_type {\n+\tHINIC_MSG_ACK = 0,\n+\tHINIC_MSG_NO_ACK = 1,\n+};\n+\n+struct hinic_recv_msg {\n+\tvoid\t\t\t*msg;\n+\tvoid\t\t\t*buf_out;\n+\n+\tu16\t\t\tmsg_len;\n+\tenum hinic_mod_type\tmod;\n+\tu8\t\t\tcmd;\n+\tu16\t\t\tmsg_id;\n+\tint\t\t\tasync_mgmt_to_pf;\n+\tu8\t\t\tsed_id;\n+};\n+\n+#define HINIC_COMM_SELF_CMD_MAX 8\n+\n+enum comm_pf_to_mgmt_event_state {\n+\tSEND_EVENT_START = 0,\n+\tSEND_EVENT_TIMEOUT,\n+\tSEND_EVENT_END,\n+};\n+\n+struct hinic_msg_pf_to_mgmt {\n+\tstruct hinic_hwdev\t\t*hwdev;\n+\n+\t/* Async cmd can not be scheduling */\n+\tspinlock_t\t\t\tasync_msg_lock;\n+\t/* spinlock for sync message */\n+\tspinlock_t\t\t\tsync_msg_lock;\n+\n+\tvoid\t\t\t\t*async_msg_buf;\n+\tvoid\t\t\t\t*sync_msg_buf;\n+\n+\tstruct hinic_recv_msg\t\trecv_msg_from_mgmt;\n+\tstruct hinic_recv_msg\t\trecv_resp_msg_from_mgmt;\n+\n+\tu16\t\t\t\tasync_msg_id;\n+\tu16\t\t\t\tsync_msg_id;\n+\n+\tstruct hinic_api_cmd_chain\t*cmd_chain[HINIC_API_CMD_MAX];\n+\n+\tstruct hinic_eq *rx_aeq;\n+};\n+\n+int hinic_msg_to_mgmt_no_ack(void *hwdev, enum hinic_mod_type mod, u8 cmd,\n+\t\t\t     void *buf_in, u16 in_size, void *buf_out,\n+\t\t\t     u16 *out_size);\n+\n+int hinic_comm_pf_to_mgmt_init(struct hinic_hwdev *hwdev);\n+\n+void hinic_comm_pf_to_mgmt_free(struct hinic_hwdev *hwdev);\n+\n+int hinic_aeq_poll_msg(struct hinic_eq *eq, u32 timeout, void *param);\n+\n+int hinic_msg_to_mgmt_sync(void *hwdev, enum hinic_mod_type mod, u8 cmd,\n+\t\t\t   void *buf_in, u16 in_size,\n+\t\t\t   void *buf_out, u16 *out_size, u32 timeout);\n+\n+void hinic_dev_handle_aeq_event(struct hinic_hwdev *hwdev, void *param);\n+\n+#endif /* _HINIC_PMD_MGMT_H_ */\n",
    "prefixes": [
        "v6",
        "06/15"
    ]
}