get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 134950,
    "url": "http://patches.dpdk.org/api/patches/134950/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20231208065508.1663412-4-haijie1@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": "<20231208065508.1663412-4-haijie1@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20231208065508.1663412-4-haijie1@huawei.com",
    "date": "2023-12-08T06:55:07",
    "name": "[v4,3/4] net/hns3: refactor send mailbox function",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "3f62089ee8557dd828d472add0fd644d424e0c20",
    "submitter": {
        "id": 2935,
        "url": "http://patches.dpdk.org/api/people/2935/?format=api",
        "name": "Jie Hai",
        "email": "haijie1@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/20231208065508.1663412-4-haijie1@huawei.com/mbox/",
    "series": [
        {
            "id": 30487,
            "url": "http://patches.dpdk.org/api/series/30487/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=30487",
            "date": "2023-12-08T06:55:04",
            "name": "net/hns3: refactor mailbox",
            "version": 4,
            "mbox": "http://patches.dpdk.org/series/30487/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/134950/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/134950/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 0352E436A6;\n\tFri,  8 Dec 2023 08:09:20 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 1D78442FD9;\n\tFri,  8 Dec 2023 08:09:04 +0100 (CET)",
            "from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255])\n by mails.dpdk.org (Postfix) with ESMTP id 4CF0142FB9\n for <dev@dpdk.org>; Fri,  8 Dec 2023 08:09:00 +0100 (CET)",
            "from kwepemd100004.china.huawei.com (unknown [172.30.72.55])\n by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Smhwj3NKkz1Q6LD;\n Fri,  8 Dec 2023 15:05:09 +0800 (CST)",
            "from localhost.localdomain (10.67.165.2) by\n kwepemd100004.china.huawei.com (7.221.188.31) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id\n 15.2.1258.28; Fri, 8 Dec 2023 15:08:58 +0800"
        ],
        "From": "Jie Hai <haijie1@huawei.com>",
        "To": "<dev@dpdk.org>, Yisen Zhuang <yisen.zhuang@huawei.com>, \"Wei Hu (Xavier)\"\n <xavier.huwei@huawei.com>, Ferruh Yigit <ferruh.yigit@intel.com>,\n Huisong Li\n <lihuisong@huawei.com>, Hao Chen <chenh@yusur.tech>, Chunsong Feng\n <fengchunsong@huawei.com>",
        "CC": "<fengchengwen@huawei.com>, <liudongdong3@huawei.com>, <haijie1@huawei.com>",
        "Subject": "[PATCH v4 3/4] net/hns3: refactor send mailbox function",
        "Date": "Fri, 8 Dec 2023 14:55:07 +0800",
        "Message-ID": "<20231208065508.1663412-4-haijie1@huawei.com>",
        "X-Mailer": "git-send-email 2.30.0",
        "In-Reply-To": "<20231208065508.1663412-1-haijie1@huawei.com>",
        "References": "<20231108034434.559030-1-haijie1@huawei.com>\n <20231208065508.1663412-1-haijie1@huawei.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.67.165.2]",
        "X-ClientProxiedBy": "dggems702-chm.china.huawei.com (10.3.19.179) To\n kwepemd100004.china.huawei.com (7.221.188.31)",
        "X-CFilter-Loop": "Reflected",
        "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": "From: Dengdui Huang <huangdengdui@huawei.com>\n\nThe 'hns3_send_mbx_msg' function has following problem:\n1. the name is vague, missing caller indication\n2. too many input parameters because the filling messages\n   are placed in commands the send command.\n\nTherefore, a common interface is encapsulated to fill in\nthe mailbox message before sending it.\n\nFixes: 463e748964f5 (\"net/hns3: support mailbox\")\nCc: stable@dpdk.org\n\nSigned-off-by: Dengdui Huang <huangdengdui@huawei.com>\nSigned-off-by: Jie Hai <haijie1@huawei.com>\n---\n drivers/net/hns3/hns3_ethdev_vf.c | 141 ++++++++++++++++++------------\n drivers/net/hns3/hns3_mbx.c       |  50 ++++-------\n drivers/net/hns3/hns3_mbx.h       |   8 +-\n drivers/net/hns3/hns3_rxtx.c      |  18 ++--\n 4 files changed, 116 insertions(+), 101 deletions(-)",
    "diff": "diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c\nindex 19e734ca8d8e..b0d0c29df191 100644\n--- a/drivers/net/hns3/hns3_ethdev_vf.c\n+++ b/drivers/net/hns3/hns3_ethdev_vf.c\n@@ -91,11 +91,13 @@ hns3vf_add_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)\n {\n \t/* mac address was checked by upper level interface */\n \tchar mac_str[RTE_ETHER_ADDR_FMT_SIZE];\n+\tstruct hns3_vf_to_pf_msg req;\n \tint ret;\n \n-\tret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_UNICAST,\n-\t\t\t\tHNS3_MBX_MAC_VLAN_UC_ADD, mac_addr->addr_bytes,\n-\t\t\t\tRTE_ETHER_ADDR_LEN, false, NULL, 0);\n+\thns3vf_mbx_setup(&req, HNS3_MBX_SET_UNICAST,\n+\t\t\t HNS3_MBX_MAC_VLAN_UC_ADD);\n+\tmemcpy(req.data, mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN);\n+\tret = hns3vf_mbx_send(hw, &req, false, NULL, 0);\n \tif (ret) {\n \t\thns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,\n \t\t\t\t      mac_addr);\n@@ -110,12 +112,13 @@ hns3vf_remove_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)\n {\n \t/* mac address was checked by upper level interface */\n \tchar mac_str[RTE_ETHER_ADDR_FMT_SIZE];\n+\tstruct hns3_vf_to_pf_msg req;\n \tint ret;\n \n-\tret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_UNICAST,\n-\t\t\t\tHNS3_MBX_MAC_VLAN_UC_REMOVE,\n-\t\t\t\tmac_addr->addr_bytes, RTE_ETHER_ADDR_LEN,\n-\t\t\t\tfalse, NULL, 0);\n+\thns3vf_mbx_setup(&req, HNS3_MBX_SET_UNICAST,\n+\t\t\t HNS3_MBX_MAC_VLAN_UC_REMOVE);\n+\tmemcpy(req.data, mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN);\n+\tret = hns3vf_mbx_send(hw, &req, false, NULL, 0);\n \tif (ret) {\n \t\thns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,\n \t\t\t\t       mac_addr);\n@@ -134,6 +137,7 @@ hns3vf_set_default_mac_addr(struct rte_eth_dev *dev,\n \tstruct rte_ether_addr *old_addr;\n \tuint8_t addr_bytes[HNS3_TWO_ETHER_ADDR_LEN]; /* for 2 MAC addresses */\n \tchar mac_str[RTE_ETHER_ADDR_FMT_SIZE];\n+\tstruct hns3_vf_to_pf_msg req;\n \tint ret;\n \n \t/*\n@@ -146,9 +150,10 @@ hns3vf_set_default_mac_addr(struct rte_eth_dev *dev,\n \tmemcpy(&addr_bytes[RTE_ETHER_ADDR_LEN], old_addr->addr_bytes,\n \t       RTE_ETHER_ADDR_LEN);\n \n-\tret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_UNICAST,\n-\t\t\t\tHNS3_MBX_MAC_VLAN_UC_MODIFY, addr_bytes,\n-\t\t\t\tHNS3_TWO_ETHER_ADDR_LEN, true, NULL, 0);\n+\thns3vf_mbx_setup(&req, HNS3_MBX_SET_UNICAST,\n+\t\t\t HNS3_MBX_MAC_VLAN_UC_MODIFY);\n+\tmemcpy(req.data, addr_bytes, HNS3_TWO_ETHER_ADDR_LEN);\n+\tret = hns3vf_mbx_send(hw, &req, true, NULL, 0);\n \tif (ret) {\n \t\t/*\n \t\t * The hns3 VF PMD depends on the hns3 PF kernel ethdev\n@@ -185,12 +190,13 @@ hns3vf_add_mc_mac_addr(struct hns3_hw *hw,\n \t\t       struct rte_ether_addr *mac_addr)\n {\n \tchar mac_str[RTE_ETHER_ADDR_FMT_SIZE];\n+\tstruct hns3_vf_to_pf_msg req;\n \tint ret;\n \n-\tret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_MULTICAST,\n-\t\t\t\tHNS3_MBX_MAC_VLAN_MC_ADD,\n-\t\t\t\tmac_addr->addr_bytes, RTE_ETHER_ADDR_LEN, false,\n-\t\t\t\tNULL, 0);\n+\thns3vf_mbx_setup(&req, HNS3_MBX_SET_MULTICAST,\n+\t\t\t HNS3_MBX_MAC_VLAN_MC_ADD);\n+\tmemcpy(req.data, mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN);\n+\tret = hns3vf_mbx_send(hw, &req, false, NULL, 0);\n \tif (ret) {\n \t\thns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,\n \t\t\t\t      mac_addr);\n@@ -206,12 +212,13 @@ hns3vf_remove_mc_mac_addr(struct hns3_hw *hw,\n \t\t\t  struct rte_ether_addr *mac_addr)\n {\n \tchar mac_str[RTE_ETHER_ADDR_FMT_SIZE];\n+\tstruct hns3_vf_to_pf_msg req;\n \tint ret;\n \n-\tret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_MULTICAST,\n-\t\t\t\tHNS3_MBX_MAC_VLAN_MC_REMOVE,\n-\t\t\t\tmac_addr->addr_bytes, RTE_ETHER_ADDR_LEN, false,\n-\t\t\t\tNULL, 0);\n+\thns3vf_mbx_setup(&req, HNS3_MBX_SET_MULTICAST,\n+\t\t\t HNS3_MBX_MAC_VLAN_MC_REMOVE);\n+\tmemcpy(req.data, mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN);\n+\tret = hns3vf_mbx_send(hw, &req, false, NULL, 0);\n \tif (ret) {\n \t\thns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,\n \t\t\t\t       mac_addr);\n@@ -348,7 +355,6 @@ hns3vf_bind_ring_with_vector(struct hns3_hw *hw, uint16_t vector_id,\n \t\t\t     bool mmap, enum hns3_ring_type queue_type,\n \t\t\t     uint16_t queue_id)\n {\n-#define HNS3_RING_VERCTOR_DATA_SIZE\t14\n \tstruct hns3_vf_to_pf_msg req = {0};\n \tconst char *op_str;\n \tint ret;\n@@ -365,8 +371,7 @@ hns3vf_bind_ring_with_vector(struct hns3_hw *hw, uint16_t vector_id,\n \treq.ring_param[0].ring_type = queue_type;\n \treq.ring_param[0].tqp_index = queue_id;\n \top_str = mmap ? \"Map\" : \"Unmap\";\n-\tret = hns3_send_mbx_msg(hw, req.code, 0, (uint8_t *)&req.vector_id,\n-\t\t\t\tHNS3_RING_VERCTOR_DATA_SIZE, false, NULL, 0);\n+\tret = hns3vf_mbx_send(hw, &req, false, NULL, 0);\n \tif (ret)\n \t\thns3_err(hw, \"%s TQP %u fail, vector_id is %u, ret = %d.\",\n \t\t\t op_str, queue_id, req.vector_id, ret);\n@@ -452,10 +457,12 @@ hns3vf_dev_configure(struct rte_eth_dev *dev)\n static int\n hns3vf_config_mtu(struct hns3_hw *hw, uint16_t mtu)\n {\n+\tstruct hns3_vf_to_pf_msg req;\n \tint ret;\n \n-\tret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_MTU, 0, (const uint8_t *)&mtu,\n-\t\t\t\tsizeof(mtu), true, NULL, 0);\n+\thns3vf_mbx_setup(&req, HNS3_MBX_SET_MTU, 0);\n+\tmemcpy(req.data, &mtu, sizeof(mtu));\n+\tret = hns3vf_mbx_send(hw, &req, true, NULL, 0);\n \tif (ret)\n \t\thns3_err(hw, \"Failed to set mtu (%u) for vf: %d\", mtu, ret);\n \n@@ -646,12 +653,13 @@ hns3vf_get_push_lsc_cap(struct hns3_hw *hw)\n \tuint16_t val = HNS3_PF_PUSH_LSC_CAP_NOT_SUPPORTED;\n \tuint16_t exp = HNS3_PF_PUSH_LSC_CAP_UNKNOWN;\n \tstruct hns3_vf *vf = HNS3_DEV_HW_TO_VF(hw);\n+\tstruct hns3_vf_to_pf_msg req;\n \n \t__atomic_store_n(&vf->pf_push_lsc_cap, HNS3_PF_PUSH_LSC_CAP_UNKNOWN,\n \t\t\t __ATOMIC_RELEASE);\n \n-\t(void)hns3_send_mbx_msg(hw, HNS3_MBX_GET_LINK_STATUS, 0, NULL, 0, false,\n-\t\t\t\tNULL, 0);\n+\thns3vf_mbx_setup(&req, HNS3_MBX_GET_LINK_STATUS, 0);\n+\t(void)hns3vf_mbx_send(hw, &req, false, NULL, 0);\n \n \twhile (remain_ms > 0) {\n \t\trte_delay_ms(HNS3_POLL_RESPONE_MS);\n@@ -746,12 +754,13 @@ hns3vf_check_tqp_info(struct hns3_hw *hw)\n static int\n hns3vf_get_port_base_vlan_filter_state(struct hns3_hw *hw)\n {\n+\tstruct hns3_vf_to_pf_msg req;\n \tuint8_t resp_msg;\n \tint ret;\n \n-\tret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_VLAN,\n-\t\t\t\tHNS3_MBX_GET_PORT_BASE_VLAN_STATE, NULL, 0,\n-\t\t\t\ttrue, &resp_msg, sizeof(resp_msg));\n+\thns3vf_mbx_setup(&req, HNS3_MBX_SET_VLAN,\n+\t\t\t HNS3_MBX_GET_PORT_BASE_VLAN_STATE);\n+\tret = hns3vf_mbx_send(hw, &req, true, &resp_msg, sizeof(resp_msg));\n \tif (ret) {\n \t\tif (ret == -ETIME) {\n \t\t\t/*\n@@ -792,10 +801,12 @@ hns3vf_get_queue_info(struct hns3_hw *hw)\n {\n #define HNS3VF_TQPS_RSS_INFO_LEN\t6\n \tuint8_t resp_msg[HNS3VF_TQPS_RSS_INFO_LEN];\n+\tstruct hns3_vf_to_pf_msg req;\n \tint ret;\n \n-\tret = hns3_send_mbx_msg(hw, HNS3_MBX_GET_QINFO, 0, NULL, 0, true,\n-\t\t\t\tresp_msg, HNS3VF_TQPS_RSS_INFO_LEN);\n+\thns3vf_mbx_setup(&req, HNS3_MBX_GET_QINFO, 0);\n+\tret = hns3vf_mbx_send(hw, &req, true,\n+\t\t\t      resp_msg, HNS3VF_TQPS_RSS_INFO_LEN);\n \tif (ret) {\n \t\tPMD_INIT_LOG(ERR, \"Failed to get tqp info from PF: %d\", ret);\n \t\treturn ret;\n@@ -833,10 +844,11 @@ hns3vf_get_basic_info(struct hns3_hw *hw)\n {\n \tuint8_t resp_msg[HNS3_MBX_MAX_RESP_DATA_SIZE];\n \tstruct hns3_basic_info *basic_info;\n+\tstruct hns3_vf_to_pf_msg req;\n \tint ret;\n \n-\tret = hns3_send_mbx_msg(hw, HNS3_MBX_GET_BASIC_INFO, 0, NULL, 0,\n-\t\t\t\ttrue, resp_msg, sizeof(resp_msg));\n+\thns3vf_mbx_setup(&req, HNS3_MBX_GET_BASIC_INFO, 0);\n+\tret = hns3vf_mbx_send(hw, &req, true, resp_msg, sizeof(resp_msg));\n \tif (ret) {\n \t\thns3_err(hw, \"failed to get basic info from PF, ret = %d.\",\n \t\t\t\tret);\n@@ -856,10 +868,11 @@ static int\n hns3vf_get_host_mac_addr(struct hns3_hw *hw)\n {\n \tuint8_t host_mac[RTE_ETHER_ADDR_LEN];\n+\tstruct hns3_vf_to_pf_msg req;\n \tint ret;\n \n-\tret = hns3_send_mbx_msg(hw, HNS3_MBX_GET_MAC_ADDR, 0, NULL, 0,\n-\t\t\t\ttrue, host_mac, RTE_ETHER_ADDR_LEN);\n+\thns3vf_mbx_setup(&req, HNS3_MBX_GET_MAC_ADDR, 0);\n+\tret = hns3vf_mbx_send(hw, &req, true, host_mac, RTE_ETHER_ADDR_LEN);\n \tif (ret) {\n \t\thns3_err(hw, \"Failed to get mac addr from PF: %d\", ret);\n \t\treturn ret;\n@@ -908,6 +921,7 @@ static void\n hns3vf_request_link_info(struct hns3_hw *hw)\n {\n \tstruct hns3_vf *vf = HNS3_DEV_HW_TO_VF(hw);\n+\tstruct hns3_vf_to_pf_msg req;\n \tbool send_req;\n \tint ret;\n \n@@ -919,8 +933,8 @@ hns3vf_request_link_info(struct hns3_hw *hw)\n \tif (!send_req)\n \t\treturn;\n \n-\tret = hns3_send_mbx_msg(hw, HNS3_MBX_GET_LINK_STATUS, 0, NULL, 0, false,\n-\t\t\t\tNULL, 0);\n+\thns3vf_mbx_setup(&req, HNS3_MBX_GET_LINK_STATUS, 0);\n+\tret = hns3vf_mbx_send(hw, &req, false, NULL, 0);\n \tif (ret) {\n \t\thns3_err(hw, \"failed to fetch link status, ret = %d\", ret);\n \t\treturn;\n@@ -964,16 +978,18 @@ hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status,\n static int\n hns3vf_vlan_filter_configure(struct hns3_adapter *hns, uint16_t vlan_id, int on)\n {\n-\tstruct hns3_mbx_vlan_filter vlan_filter = {0};\n+\tstruct hns3_mbx_vlan_filter *vlan_filter;\n+\tstruct hns3_vf_to_pf_msg req = {0};\n \tstruct hns3_hw *hw = &hns->hw;\n \n-\tvlan_filter.is_kill = on ? 0 : 1;\n-\tvlan_filter.proto = rte_cpu_to_le_16(RTE_ETHER_TYPE_VLAN);\n-\tvlan_filter.vlan_id =  rte_cpu_to_le_16(vlan_id);\n+\treq.code = HNS3_MBX_SET_VLAN;\n+\treq.subcode = HNS3_MBX_VLAN_FILTER;\n+\tvlan_filter = (struct hns3_mbx_vlan_filter *)req.data;\n+\tvlan_filter->is_kill = on ? 0 : 1;\n+\tvlan_filter->proto = rte_cpu_to_le_16(RTE_ETHER_TYPE_VLAN);\n+\tvlan_filter->vlan_id = rte_cpu_to_le_16(vlan_id);\n \n-\treturn hns3_send_mbx_msg(hw, HNS3_MBX_SET_VLAN, HNS3_MBX_VLAN_FILTER,\n-\t\t\t\t(uint8_t *)&vlan_filter, sizeof(vlan_filter),\n-\t\t\t\t true, NULL, 0);\n+\treturn hns3vf_mbx_send(hw, &req, true, NULL, 0);\n }\n \n static int\n@@ -1002,6 +1018,7 @@ hns3vf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)\n static int\n hns3vf_en_vlan_filter(struct hns3_hw *hw, bool enable)\n {\n+\tstruct hns3_vf_to_pf_msg req;\n \tuint8_t msg_data;\n \tint ret;\n \n@@ -1009,9 +1026,10 @@ hns3vf_en_vlan_filter(struct hns3_hw *hw, bool enable)\n \t\treturn 0;\n \n \tmsg_data = enable ? 1 : 0;\n-\tret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_VLAN,\n-\t\t\tHNS3_MBX_ENABLE_VLAN_FILTER, &msg_data,\n-\t\t\tsizeof(msg_data), true, NULL, 0);\n+\thns3vf_mbx_setup(&req, HNS3_MBX_SET_VLAN,\n+\t\t\t HNS3_MBX_ENABLE_VLAN_FILTER);\n+\tmemcpy(req.data, &msg_data, sizeof(msg_data));\n+\tret = hns3vf_mbx_send(hw, &req, true, NULL, 0);\n \tif (ret)\n \t\thns3_err(hw, \"%s vlan filter failed, ret = %d.\",\n \t\t\t\tenable ? \"enable\" : \"disable\", ret);\n@@ -1022,12 +1040,15 @@ hns3vf_en_vlan_filter(struct hns3_hw *hw, bool enable)\n static int\n hns3vf_en_hw_strip_rxvtag(struct hns3_hw *hw, bool enable)\n {\n+\tstruct hns3_vf_to_pf_msg req;\n \tuint8_t msg_data;\n \tint ret;\n \n \tmsg_data = enable ? 1 : 0;\n-\tret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_VLAN, HNS3_MBX_VLAN_RX_OFF_CFG,\n-\t\t\t\t&msg_data, sizeof(msg_data), false, NULL, 0);\n+\thns3vf_mbx_setup(&req, HNS3_MBX_SET_VLAN,\n+\t\t\t HNS3_MBX_VLAN_RX_OFF_CFG);\n+\tmemcpy(req.data, &msg_data, sizeof(msg_data));\n+\tret = hns3vf_mbx_send(hw, &req, false, NULL, 0);\n \tif (ret)\n \t\thns3_err(hw, \"vf %s strip failed, ret = %d.\",\n \t\t\t\tenable ? \"enable\" : \"disable\", ret);\n@@ -1171,11 +1192,13 @@ hns3vf_dev_configure_vlan(struct rte_eth_dev *dev)\n static int\n hns3vf_set_alive(struct hns3_hw *hw, bool alive)\n {\n+\tstruct hns3_vf_to_pf_msg req;\n \tuint8_t msg_data;\n \n \tmsg_data = alive ? 1 : 0;\n-\treturn hns3_send_mbx_msg(hw, HNS3_MBX_SET_ALIVE, 0, &msg_data,\n-\t\t\t\t sizeof(msg_data), false, NULL, 0);\n+\thns3vf_mbx_setup(&req, HNS3_MBX_SET_ALIVE, 0);\n+\tmemcpy(req.data, &msg_data, sizeof(msg_data));\n+\treturn hns3vf_mbx_send(hw, &req, false, NULL, 0);\n }\n \n static void\n@@ -1183,11 +1206,12 @@ hns3vf_keep_alive_handler(void *param)\n {\n \tstruct rte_eth_dev *eth_dev = (struct rte_eth_dev *)param;\n \tstruct hns3_adapter *hns = eth_dev->data->dev_private;\n+\tstruct hns3_vf_to_pf_msg req;\n \tstruct hns3_hw *hw = &hns->hw;\n \tint ret;\n \n-\tret = hns3_send_mbx_msg(hw, HNS3_MBX_KEEP_ALIVE, 0, NULL, 0,\n-\t\t\t\tfalse, NULL, 0);\n+\thns3vf_mbx_setup(&req, HNS3_MBX_KEEP_ALIVE, 0);\n+\tret = hns3vf_mbx_send(hw, &req, false, NULL, 0);\n \tif (ret)\n \t\thns3_err(hw, \"VF sends keeping alive cmd failed(=%d)\",\n \t\t\t ret);\n@@ -1326,9 +1350,11 @@ hns3vf_init_hardware(struct hns3_adapter *hns)\n static int\n hns3vf_clear_vport_list(struct hns3_hw *hw)\n {\n-\treturn hns3_send_mbx_msg(hw, HNS3_MBX_HANDLE_VF_TBL,\n-\t\t\t\t HNS3_MBX_VPORT_LIST_CLEAR, NULL, 0, false,\n-\t\t\t\t NULL, 0);\n+\tstruct hns3_vf_to_pf_msg req;\n+\n+\thns3vf_mbx_setup(&req, HNS3_MBX_HANDLE_VF_TBL,\n+\t\t\t HNS3_MBX_VPORT_LIST_CLEAR);\n+\treturn hns3vf_mbx_send(hw, &req, false, NULL, 0);\n }\n \n static int\n@@ -1797,12 +1823,13 @@ hns3vf_wait_hardware_ready(struct hns3_adapter *hns)\n static int\n hns3vf_prepare_reset(struct hns3_adapter *hns)\n {\n+\tstruct hns3_vf_to_pf_msg req;\n \tstruct hns3_hw *hw = &hns->hw;\n \tint ret;\n \n \tif (hw->reset.level == HNS3_VF_FUNC_RESET) {\n-\t\tret = hns3_send_mbx_msg(hw, HNS3_MBX_RESET, 0, NULL,\n-\t\t\t\t\t0, true, NULL, 0);\n+\t\thns3vf_mbx_setup(&req, HNS3_MBX_RESET, 0);\n+\t\tret = hns3vf_mbx_send(hw, &req, true, NULL, 0);\n \t\tif (ret)\n \t\t\treturn ret;\n \t}\ndiff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c\nindex c90f5d59ba21..43195ff184b1 100644\n--- a/drivers/net/hns3/hns3_mbx.c\n+++ b/drivers/net/hns3/hns3_mbx.c\n@@ -24,6 +24,14 @@ static const struct errno_respcode_map err_code_map[] = {\n \t{95, -EOPNOTSUPP},\n };\n \n+void\n+hns3vf_mbx_setup(struct hns3_vf_to_pf_msg *req, uint8_t code, uint8_t subcode)\n+{\n+\tmemset(req, 0, sizeof(struct hns3_vf_to_pf_msg));\n+\treq->code = code;\n+\treq->subcode = subcode;\n+}\n+\n static int\n hns3_resp_to_errno(uint16_t resp_code)\n {\n@@ -118,45 +126,24 @@ hns3_mbx_prepare_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode)\n }\n \n int\n-hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode,\n-\t\t  const uint8_t *msg_data, uint8_t msg_len, bool need_resp,\n-\t\t  uint8_t *resp_data, uint16_t resp_len)\n+hns3vf_mbx_send(struct hns3_hw *hw,\n+\t\tstruct hns3_vf_to_pf_msg *req, bool need_resp,\n+\t\tuint8_t *resp_data, uint16_t resp_len)\n {\n-\tstruct hns3_mbx_vf_to_pf_cmd *req;\n+\tstruct hns3_mbx_vf_to_pf_cmd *cmd;\n \tstruct hns3_cmd_desc desc;\n-\tbool is_ring_vector_msg;\n \tint ret;\n \n-\treq = (struct hns3_mbx_vf_to_pf_cmd *)desc.data;\n-\n-\t/* first two bytes are reserved for code & subcode */\n-\tif (msg_len > HNS3_MBX_MSG_MAX_DATA_SIZE) {\n-\t\thns3_err(hw,\n-\t\t\t \"VF send mbx msg fail, msg len %u exceeds max payload len %d\",\n-\t\t\t msg_len, HNS3_MBX_MSG_MAX_DATA_SIZE);\n-\t\treturn -EINVAL;\n-\t}\n-\n \thns3_cmd_setup_basic_desc(&desc, HNS3_OPC_MBX_VF_TO_PF, false);\n-\treq->msg.code = code;\n-\tis_ring_vector_msg = (code == HNS3_MBX_MAP_RING_TO_VECTOR) ||\n-\t\t\t     (code == HNS3_MBX_UNMAP_RING_TO_VECTOR) ||\n-\t\t\t     (code == HNS3_MBX_GET_RING_VECTOR_MAP);\n-\tif (!is_ring_vector_msg)\n-\t\treq->msg.subcode = subcode;\n-\tif (msg_data) {\n-\t\tif (is_ring_vector_msg)\n-\t\t\tmemcpy(&req->msg.vector_id, msg_data, msg_len);\n-\t\telse\n-\t\t\tmemcpy(&req->msg.data, msg_data, msg_len);\n-\t}\n+\tcmd = (struct hns3_mbx_vf_to_pf_cmd *)desc.data;\n+\tcmd->msg = *req;\n \n \t/* synchronous send */\n \tif (need_resp) {\n-\t\treq->mbx_need_resp |= HNS3_MBX_NEED_RESP_BIT;\n+\t\tcmd->mbx_need_resp |= HNS3_MBX_NEED_RESP_BIT;\n \t\trte_spinlock_lock(&hw->mbx_resp.lock);\n-\t\thns3_mbx_prepare_resp(hw, code, subcode);\n-\t\treq->match_id = hw->mbx_resp.match_id;\n+\t\thns3_mbx_prepare_resp(hw, req->code, req->subcode);\n+\t\tcmd->match_id = hw->mbx_resp.match_id;\n \t\tret = hns3_cmd_send(hw, &desc, 1);\n \t\tif (ret) {\n \t\t\trte_spinlock_unlock(&hw->mbx_resp.lock);\n@@ -165,7 +152,8 @@ hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode,\n \t\t\treturn ret;\n \t\t}\n \n-\t\tret = hns3_get_mbx_resp(hw, code, subcode, resp_data, resp_len);\n+\t\tret = hns3_get_mbx_resp(hw, req->code, req->subcode,\n+\t\t\t\t\tresp_data, resp_len);\n \t\trte_spinlock_unlock(&hw->mbx_resp.lock);\n \t} else {\n \t\t/* asynchronous send */\ndiff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h\nindex 09780fcebdb2..2952b96ab6b3 100644\n--- a/drivers/net/hns3/hns3_mbx.h\n+++ b/drivers/net/hns3/hns3_mbx.h\n@@ -208,7 +208,9 @@ struct hns3_pf_rst_done_cmd {\n \n struct hns3_hw;\n void hns3_dev_handle_mbx_msg(struct hns3_hw *hw);\n-int hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode,\n-\t\t      const uint8_t *msg_data, uint8_t msg_len, bool need_resp,\n-\t\t      uint8_t *resp_data, uint16_t resp_len);\n+void hns3vf_mbx_setup(struct hns3_vf_to_pf_msg *req,\n+\t\t      uint8_t code, uint8_t subcode);\n+int hns3vf_mbx_send(struct hns3_hw *hw,\n+\t\t    struct hns3_vf_to_pf_msg *req_msg, bool need_resp,\n+\t\t    uint8_t *resp_data, uint16_t resp_len);\n #endif /* HNS3_MBX_H */\ndiff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c\nindex 09b7e90c7000..9087bcffed9b 100644\n--- a/drivers/net/hns3/hns3_rxtx.c\n+++ b/drivers/net/hns3/hns3_rxtx.c\n@@ -686,13 +686,12 @@ hns3pf_reset_tqp(struct hns3_hw *hw, uint16_t queue_id)\n static int\n hns3vf_reset_tqp(struct hns3_hw *hw, uint16_t queue_id)\n {\n-\tuint8_t msg_data[2];\n+\tstruct hns3_vf_to_pf_msg req;\n \tint ret;\n \n-\tmemcpy(msg_data, &queue_id, sizeof(uint16_t));\n-\n-\tret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data,\n-\t\t\t\t sizeof(msg_data), true, NULL, 0);\n+\thns3vf_mbx_setup(&req, HNS3_MBX_QUEUE_RESET, 0);\n+\tmemcpy(req.data, &queue_id, sizeof(uint16_t));\n+\tret = hns3vf_mbx_send(hw, &req, true, NULL, 0);\n \tif (ret)\n \t\thns3_err(hw, \"fail to reset tqp, queue_id = %u, ret = %d.\",\n \t\t\t queue_id, ret);\n@@ -769,15 +768,14 @@ static int\n hns3vf_reset_all_tqps(struct hns3_hw *hw)\n {\n #define HNS3VF_RESET_ALL_TQP_DONE\t1U\n+\tstruct hns3_vf_to_pf_msg req;\n \tuint8_t reset_status;\n-\tuint8_t msg_data[2];\n \tint ret;\n \tuint16_t i;\n \n-\tmemset(msg_data, 0, sizeof(msg_data));\n-\tret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data,\n-\t\t\t\tsizeof(msg_data), true, &reset_status,\n-\t\t\t\tsizeof(reset_status));\n+\thns3vf_mbx_setup(&req, HNS3_MBX_QUEUE_RESET, 0);\n+\tret = hns3vf_mbx_send(hw, &req, true,\n+\t\t\t      &reset_status, sizeof(reset_status));\n \tif (ret) {\n \t\thns3_err(hw, \"fail to send rcb reset mbx, ret = %d.\", ret);\n \t\treturn ret;\n",
    "prefixes": [
        "v4",
        "3/4"
    ]
}