get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 98303,
    "url": "http://patches.dpdk.org/api/patches/98303/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20210908083758.312055-20-jiawenwu@trustnetic.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": "<20210908083758.312055-20-jiawenwu@trustnetic.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210908083758.312055-20-jiawenwu@trustnetic.com",
    "date": "2021-09-08T08:37:45",
    "name": "[19/32] net/ngbe: add mailbox process operations",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "4477c297586ff6cf48ff4038fc59a08c25655b59",
    "submitter": {
        "id": 1932,
        "url": "http://patches.dpdk.org/api/people/1932/?format=api",
        "name": "Jiawen Wu",
        "email": "jiawenwu@trustnetic.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/20210908083758.312055-20-jiawenwu@trustnetic.com/mbox/",
    "series": [
        {
            "id": 18760,
            "url": "http://patches.dpdk.org/api/series/18760/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=18760",
            "date": "2021-09-08T08:37:26",
            "name": "net/ngbe: add many features",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/18760/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/98303/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/98303/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 5DF08A0C56;\n\tWed,  8 Sep 2021 10:38:47 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id C188B411FC;\n\tWed,  8 Sep 2021 10:37:10 +0200 (CEST)",
            "from smtpbgau1.qq.com (smtpbgau1.qq.com [54.206.16.166])\n by mails.dpdk.org (Postfix) with ESMTP id 8042941180\n for <dev@dpdk.org>; Wed,  8 Sep 2021 10:37:04 +0200 (CEST)",
            "from wxdbg.localdomain.com (unknown [183.129.236.74])\n by esmtp6.qq.com (ESMTP) with\n id ; Wed, 08 Sep 2021 16:36:55 +0800 (CST)"
        ],
        "X-QQ-mid": "bizesmtp47t1631090216tp3d0wnm",
        "X-QQ-SSF": "01400000002000E0G000B00A0000000",
        "X-QQ-FEAT": "xqT8U4SkSphNzAyzmJu/g59/bfEsvHK+ASN4y0rjJ+4bZizucS0pC5pLG6A0q\n KjHF+8nFZapVA71lUHt9O5Rah+ML+TqOwP/G6+6EmqihwLP8zdHTmvCKPNWXeAoDTtjGw5g\n Xhxq22c68GDWa3ymiNPvnGzcm6oO5LQG8clqQJCr+OgEutUl4vnhvQTtp3Vru3b7YDu40X/\n 1aMXAQTscVxoexMM9rrA+PTnSoDqMs3FnvVSwZL/H0ZkOLKL1ggTfSPQE+79BlITFC4nC8s\n o/6QEJrFAgsP7K/qEKX6SzobAihV0RiHsPF6EGJvC/1FTIm1fuw/kbvttKIqyf743PNfkYZ\n ocCDGEv/u7dPzLkwqFVATgccW7ainaMSPJc0ibr",
        "X-QQ-GoodBg": "2",
        "From": "Jiawen Wu <jiawenwu@trustnetic.com>",
        "To": "dev@dpdk.org",
        "Cc": "Jiawen Wu <jiawenwu@trustnetic.com>",
        "Date": "Wed,  8 Sep 2021 16:37:45 +0800",
        "Message-Id": "<20210908083758.312055-20-jiawenwu@trustnetic.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20210908083758.312055-1-jiawenwu@trustnetic.com>",
        "References": "<20210908083758.312055-1-jiawenwu@trustnetic.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-QQ-SENDSIZE": "520",
        "Feedback-ID": "bizesmtp:trustnetic.com:qybgforeign:qybgforeign1",
        "X-QQ-Bgrelay": "1",
        "Subject": "[dpdk-dev] [PATCH 19/32] net/ngbe: add mailbox process operations",
        "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 check operation for vf function level reset,\nmailbox messages and ack from vf.\nWaiting to process the messages.\n\nSigned-off-by: Jiawen Wu <jiawenwu@trustnetic.com>\n---\n drivers/net/ngbe/base/ngbe.h       |   4 +\n drivers/net/ngbe/base/ngbe_dummy.h |  39 ++\n drivers/net/ngbe/base/ngbe_hw.c    | 215 +++++++++++\n drivers/net/ngbe/base/ngbe_hw.h    |   8 +\n drivers/net/ngbe/base/ngbe_mbx.c   | 297 +++++++++++++++\n drivers/net/ngbe/base/ngbe_mbx.h   |  78 ++++\n drivers/net/ngbe/base/ngbe_type.h  |  10 +\n drivers/net/ngbe/meson.build       |   2 +\n drivers/net/ngbe/ngbe_ethdev.c     |   7 +\n drivers/net/ngbe/ngbe_ethdev.h     |  13 +\n drivers/net/ngbe/ngbe_pf.c         | 564 +++++++++++++++++++++++++++++\n drivers/net/ngbe/rte_pmd_ngbe.h    |  39 ++\n 12 files changed, 1276 insertions(+)\n create mode 100644 drivers/net/ngbe/rte_pmd_ngbe.h",
    "diff": "diff --git a/drivers/net/ngbe/base/ngbe.h b/drivers/net/ngbe/base/ngbe.h\nindex fe85b07b57..1d17c2f115 100644\n--- a/drivers/net/ngbe/base/ngbe.h\n+++ b/drivers/net/ngbe/base/ngbe.h\n@@ -6,6 +6,10 @@\n #define _NGBE_H_\n \n #include \"ngbe_type.h\"\n+#include \"ngbe_mng.h\"\n+#include \"ngbe_mbx.h\"\n+#include \"ngbe_eeprom.h\"\n+#include \"ngbe_phy.h\"\n #include \"ngbe_hw.h\"\n \n #endif /* _NGBE_H_ */\ndiff --git a/drivers/net/ngbe/base/ngbe_dummy.h b/drivers/net/ngbe/base/ngbe_dummy.h\nindex 5cb09bfcaa..940b448734 100644\n--- a/drivers/net/ngbe/base/ngbe_dummy.h\n+++ b/drivers/net/ngbe/base/ngbe_dummy.h\n@@ -136,6 +136,16 @@ static inline s32 ngbe_mac_clear_vfta_dummy(struct ngbe_hw *TUP0)\n {\n \treturn NGBE_ERR_OPS_DUMMY;\n }\n+static inline s32 ngbe_mac_set_vfta_dummy(struct ngbe_hw *TUP0, u32 TUP1,\n+\t\t\t\t\tu32 TUP2, bool TUP3, bool TUP4)\n+{\n+\treturn NGBE_ERR_OPS_DUMMY;\n+}\n+static inline s32 ngbe_mac_set_vlvf_dummy(struct ngbe_hw *TUP0, u32 TUP1,\n+\t\t\tu32 TUP2, bool TUP3, u32 *TUP4, u32 TUP5, bool TUP6)\n+{\n+\treturn NGBE_ERR_OPS_DUMMY;\n+}\n static inline void ngbe_mac_set_mac_anti_spoofing_dummy(struct ngbe_hw *TUP0,\n \t\t\t\t\tbool TUP1, int TUP2)\n {\n@@ -200,6 +210,28 @@ static inline s32 ngbe_phy_check_link_dummy(struct ngbe_hw *TUP0, u32 *TUP1,\n static inline void ngbe_mbx_init_params_dummy(struct ngbe_hw *TUP0)\n {\n }\n+static inline s32 ngbe_mbx_read_dummy(struct ngbe_hw *TUP0, u32 *TUP1,\n+\t\t\t\t\tu16 TUP2, u16 TUP3)\n+{\n+\treturn NGBE_ERR_OPS_DUMMY;\n+}\n+static inline s32 ngbe_mbx_write_dummy(struct ngbe_hw *TUP0, u32 *TUP1,\n+\t\t\t\t\tu16 TUP2, u16 TUP3)\n+{\n+\treturn NGBE_ERR_OPS_DUMMY;\n+}\n+static inline s32 ngbe_mbx_check_for_msg_dummy(struct ngbe_hw *TUP0, u16 TUP1)\n+{\n+\treturn NGBE_ERR_OPS_DUMMY;\n+}\n+static inline s32 ngbe_mbx_check_for_ack_dummy(struct ngbe_hw *TUP0, u16 TUP1)\n+{\n+\treturn NGBE_ERR_OPS_DUMMY;\n+}\n+static inline s32 ngbe_mbx_check_for_rst_dummy(struct ngbe_hw *TUP0, u16 TUP1)\n+{\n+\treturn NGBE_ERR_OPS_DUMMY;\n+}\n \n static inline void ngbe_init_ops_dummy(struct ngbe_hw *hw)\n {\n@@ -228,6 +260,8 @@ static inline void ngbe_init_ops_dummy(struct ngbe_hw *hw)\n \thw->mac.init_rx_addrs = ngbe_mac_init_rx_addrs_dummy;\n \thw->mac.update_mc_addr_list = ngbe_mac_update_mc_addr_list_dummy;\n \thw->mac.clear_vfta = ngbe_mac_clear_vfta_dummy;\n+\thw->mac.set_vfta = ngbe_mac_set_vfta_dummy;\n+\thw->mac.set_vlvf = ngbe_mac_set_vlvf_dummy;\n \thw->mac.set_mac_anti_spoofing = ngbe_mac_set_mac_anti_spoofing_dummy;\n \thw->mac.set_vlan_anti_spoofing = ngbe_mac_set_vlan_anti_spoofing_dummy;\n \thw->mac.init_thermal_sensor_thresh = ngbe_mac_init_thermal_ssth_dummy;\n@@ -242,6 +276,11 @@ static inline void ngbe_init_ops_dummy(struct ngbe_hw *hw)\n \thw->phy.setup_link = ngbe_phy_setup_link_dummy;\n \thw->phy.check_link = ngbe_phy_check_link_dummy;\n \thw->mbx.init_params = ngbe_mbx_init_params_dummy;\n+\thw->mbx.read = ngbe_mbx_read_dummy;\n+\thw->mbx.write = ngbe_mbx_write_dummy;\n+\thw->mbx.check_for_msg = ngbe_mbx_check_for_msg_dummy;\n+\thw->mbx.check_for_ack = ngbe_mbx_check_for_ack_dummy;\n+\thw->mbx.check_for_rst = ngbe_mbx_check_for_rst_dummy;\n }\n \n #endif /* _NGBE_TYPE_DUMMY_H_ */\ndiff --git a/drivers/net/ngbe/base/ngbe_hw.c b/drivers/net/ngbe/base/ngbe_hw.c\nindex 8b45a91f78..afde58a89e 100644\n--- a/drivers/net/ngbe/base/ngbe_hw.c\n+++ b/drivers/net/ngbe/base/ngbe_hw.c\n@@ -914,6 +914,214 @@ s32 ngbe_init_uta_tables(struct ngbe_hw *hw)\n \treturn 0;\n }\n \n+/**\n+ *  ngbe_find_vlvf_slot - find the vlanid or the first empty slot\n+ *  @hw: pointer to hardware structure\n+ *  @vlan: VLAN id to write to VLAN filter\n+ *  @vlvf_bypass: true to find vlanid only, false returns first empty slot if\n+ *\t\t  vlanid not found\n+ *\n+ *\n+ *  return the VLVF index where this VLAN id should be placed\n+ *\n+ **/\n+s32 ngbe_find_vlvf_slot(struct ngbe_hw *hw, u32 vlan, bool vlvf_bypass)\n+{\n+\ts32 regindex, first_empty_slot;\n+\tu32 bits;\n+\n+\t/* short cut the special case */\n+\tif (vlan == 0)\n+\t\treturn 0;\n+\n+\t/* if vlvf_bypass is set we don't want to use an empty slot, we\n+\t * will simply bypass the VLVF if there are no entries present in the\n+\t * VLVF that contain our VLAN\n+\t */\n+\tfirst_empty_slot = vlvf_bypass ? NGBE_ERR_NO_SPACE : 0;\n+\n+\t/* add VLAN enable bit for comparison */\n+\tvlan |= NGBE_PSRVLAN_EA;\n+\n+\t/* Search for the vlan id in the VLVF entries. Save off the first empty\n+\t * slot found along the way.\n+\t *\n+\t * pre-decrement loop covering (NGBE_NUM_POOL - 1) .. 1\n+\t */\n+\tfor (regindex = NGBE_NUM_POOL; --regindex;) {\n+\t\twr32(hw, NGBE_PSRVLANIDX, regindex);\n+\t\tbits = rd32(hw, NGBE_PSRVLAN);\n+\t\tif (bits == vlan)\n+\t\t\treturn regindex;\n+\t\tif (!first_empty_slot && !bits)\n+\t\t\tfirst_empty_slot = regindex;\n+\t}\n+\n+\t/* If we are here then we didn't find the VLAN.  Return first empty\n+\t * slot we found during our search, else error.\n+\t */\n+\tif (!first_empty_slot)\n+\t\tDEBUGOUT(\"No space in VLVF.\\n\");\n+\n+\treturn first_empty_slot ? first_empty_slot : NGBE_ERR_NO_SPACE;\n+}\n+\n+/**\n+ *  ngbe_set_vfta - Set VLAN filter table\n+ *  @hw: pointer to hardware structure\n+ *  @vlan: VLAN id to write to VLAN filter\n+ *  @vind: VMDq output index that maps queue to VLAN id in VLVFB\n+ *  @vlan_on: boolean flag to turn on/off VLAN\n+ *  @vlvf_bypass: boolean flag indicating updating default pool is okay\n+ *\n+ *  Turn on/off specified VLAN in the VLAN filter table.\n+ **/\n+s32 ngbe_set_vfta(struct ngbe_hw *hw, u32 vlan, u32 vind,\n+\t\t\t   bool vlan_on, bool vlvf_bypass)\n+{\n+\tu32 regidx, vfta_delta, vfta;\n+\ts32 err;\n+\n+\tDEBUGFUNC(\"ngbe_set_vfta\");\n+\n+\tif (vlan > 4095 || vind > 63)\n+\t\treturn NGBE_ERR_PARAM;\n+\n+\t/*\n+\t * this is a 2 part operation - first the VFTA, then the\n+\t * VLVF and VLVFB if VT Mode is set\n+\t * We don't write the VFTA until we know the VLVF part succeeded.\n+\t */\n+\n+\t/* Part 1\n+\t * The VFTA is a bitstring made up of 128 32-bit registers\n+\t * that enable the particular VLAN id, much like the MTA:\n+\t *    bits[11-5]: which register\n+\t *    bits[4-0]:  which bit in the register\n+\t */\n+\tregidx = vlan / 32;\n+\tvfta_delta = 1 << (vlan % 32);\n+\tvfta = rd32(hw, NGBE_VLANTBL(regidx));\n+\n+\t/*\n+\t * vfta_delta represents the difference between the current value\n+\t * of vfta and the value we want in the register.  Since the diff\n+\t * is an XOR mask we can just update the vfta using an XOR\n+\t */\n+\tvfta_delta &= vlan_on ? ~vfta : vfta;\n+\tvfta ^= vfta_delta;\n+\n+\t/* Part 2\n+\t * Call ngbe_set_vlvf to set VLVFB and VLVF\n+\t */\n+\terr = ngbe_set_vlvf(hw, vlan, vind, vlan_on, &vfta_delta,\n+\t\t\t\t\t vfta, vlvf_bypass);\n+\tif (err != 0) {\n+\t\tif (vlvf_bypass)\n+\t\t\tgoto vfta_update;\n+\t\treturn err;\n+\t}\n+\n+vfta_update:\n+\t/* Update VFTA now that we are ready for traffic */\n+\tif (vfta_delta)\n+\t\twr32(hw, NGBE_VLANTBL(regidx), vfta);\n+\n+\treturn 0;\n+}\n+\n+/**\n+ *  ngbe_set_vlvf - Set VLAN Pool Filter\n+ *  @hw: pointer to hardware structure\n+ *  @vlan: VLAN id to write to VLAN filter\n+ *  @vind: VMDq output index that maps queue to VLAN id in PSRVLANPLM\n+ *  @vlan_on: boolean flag to turn on/off VLAN in PSRVLAN\n+ *  @vfta_delta: pointer to the difference between the current value\n+ *\t\t of PSRVLANPLM and the desired value\n+ *  @vfta: the desired value of the VFTA\n+ *  @vlvf_bypass: boolean flag indicating updating default pool is okay\n+ *\n+ *  Turn on/off specified bit in VLVF table.\n+ **/\n+s32 ngbe_set_vlvf(struct ngbe_hw *hw, u32 vlan, u32 vind,\n+\t\t\t   bool vlan_on, u32 *vfta_delta, u32 vfta,\n+\t\t\t   bool vlvf_bypass)\n+{\n+\tu32 bits;\n+\tu32 portctl;\n+\ts32 vlvf_index;\n+\n+\tDEBUGFUNC(\"ngbe_set_vlvf\");\n+\n+\tif (vlan > 4095 || vind > 63)\n+\t\treturn NGBE_ERR_PARAM;\n+\n+\t/* If VT Mode is set\n+\t *   Either vlan_on\n+\t *     make sure the vlan is in PSRVLAN\n+\t *     set the vind bit in the matching PSRVLANPLM\n+\t *   Or !vlan_on\n+\t *     clear the pool bit and possibly the vind\n+\t */\n+\tportctl = rd32(hw, NGBE_PORTCTL);\n+\tif (!(portctl & NGBE_PORTCTL_NUMVT_MASK))\n+\t\treturn 0;\n+\n+\tvlvf_index = ngbe_find_vlvf_slot(hw, vlan, vlvf_bypass);\n+\tif (vlvf_index < 0)\n+\t\treturn vlvf_index;\n+\n+\twr32(hw, NGBE_PSRVLANIDX, vlvf_index);\n+\tbits = rd32(hw, NGBE_PSRVLANPLM(vind / 32));\n+\n+\t/* set the pool bit */\n+\tbits |= 1 << (vind % 32);\n+\tif (vlan_on)\n+\t\tgoto vlvf_update;\n+\n+\t/* clear the pool bit */\n+\tbits ^= 1 << (vind % 32);\n+\n+\tif (!bits &&\n+\t    !rd32(hw, NGBE_PSRVLANPLM(vind / 32))) {\n+\t\t/* Clear PSRVLANPLM first, then disable PSRVLAN. Otherwise\n+\t\t * we run the risk of stray packets leaking into\n+\t\t * the PF via the default pool\n+\t\t */\n+\t\tif (*vfta_delta)\n+\t\t\twr32(hw, NGBE_PSRVLANPLM(vlan / 32), vfta);\n+\n+\t\t/* disable VLVF and clear remaining bit from pool */\n+\t\twr32(hw, NGBE_PSRVLAN, 0);\n+\t\twr32(hw, NGBE_PSRVLANPLM(vind / 32), 0);\n+\n+\t\treturn 0;\n+\t}\n+\n+\t/* If there are still bits set in the PSRVLANPLM registers\n+\t * for the VLAN ID indicated we need to see if the\n+\t * caller is requesting that we clear the PSRVLANPLM entry bit.\n+\t * If the caller has requested that we clear the PSRVLANPLM\n+\t * entry bit but there are still pools/VFs using this VLAN\n+\t * ID entry then ignore the request.  We're not worried\n+\t * about the case where we're turning the PSRVLANPLM VLAN ID\n+\t * entry bit on, only when requested to turn it off as\n+\t * there may be multiple pools and/or VFs using the\n+\t * VLAN ID entry.  In that case we cannot clear the\n+\t * PSRVLANPLM bit until all pools/VFs using that VLAN ID have also\n+\t * been cleared.  This will be indicated by \"bits\" being\n+\t * zero.\n+\t */\n+\t*vfta_delta = 0;\n+\n+vlvf_update:\n+\t/* record pool change and enable VLAN ID if not already enabled */\n+\twr32(hw, NGBE_PSRVLANPLM(vind / 32), bits);\n+\twr32(hw, NGBE_PSRVLAN, NGBE_PSRVLAN_EA | vlan);\n+\n+\treturn 0;\n+}\n+\n /**\n  *  ngbe_clear_vfta - Clear VLAN filter table\n  *  @hw: pointer to hardware structure\n@@ -1306,6 +1514,8 @@ s32 ngbe_init_ops_pf(struct ngbe_hw *hw)\n \tmac->update_mc_addr_list = ngbe_update_mc_addr_list;\n \tmac->set_vmdq = ngbe_set_vmdq;\n \tmac->clear_vmdq = ngbe_clear_vmdq;\n+\tmac->set_vfta = ngbe_set_vfta;\n+\tmac->set_vlvf = ngbe_set_vlvf;\n \tmac->clear_vfta = ngbe_clear_vfta;\n \tmac->set_mac_anti_spoofing = ngbe_set_mac_anti_spoofing;\n \tmac->set_vlan_anti_spoofing = ngbe_set_vlan_anti_spoofing;\n@@ -1320,6 +1530,11 @@ s32 ngbe_init_ops_pf(struct ngbe_hw *hw)\n \tmac->check_overtemp = ngbe_mac_check_overtemp;\n \n \tmbx->init_params = ngbe_init_mbx_params_pf;\n+\tmbx->read = ngbe_read_mbx_pf;\n+\tmbx->write = ngbe_write_mbx_pf;\n+\tmbx->check_for_msg = ngbe_check_for_msg_pf;\n+\tmbx->check_for_ack = ngbe_check_for_ack_pf;\n+\tmbx->check_for_rst = ngbe_check_for_rst_pf;\n \n \t/* EEPROM */\n \trom->init_params = ngbe_init_eeprom_params;\ndiff --git a/drivers/net/ngbe/base/ngbe_hw.h b/drivers/net/ngbe/base/ngbe_hw.h\nindex a27bd3e650..83ad646dde 100644\n--- a/drivers/net/ngbe/base/ngbe_hw.h\n+++ b/drivers/net/ngbe/base/ngbe_hw.h\n@@ -49,8 +49,16 @@ void ngbe_release_swfw_sync(struct ngbe_hw *hw, u32 mask);\n s32 ngbe_set_vmdq(struct ngbe_hw *hw, u32 rar, u32 vmdq);\n s32 ngbe_clear_vmdq(struct ngbe_hw *hw, u32 rar, u32 vmdq);\n s32 ngbe_init_uta_tables(struct ngbe_hw *hw);\n+s32 ngbe_set_vfta(struct ngbe_hw *hw, u32 vlan,\n+\t\t\t u32 vind, bool vlan_on, bool vlvf_bypass);\n+s32 ngbe_set_vlvf(struct ngbe_hw *hw, u32 vlan, u32 vind,\n+\t\t\t   bool vlan_on, u32 *vfta_delta, u32 vfta,\n+\t\t\t   bool vlvf_bypass);\n s32 ngbe_clear_vfta(struct ngbe_hw *hw);\n+s32 ngbe_find_vlvf_slot(struct ngbe_hw *hw, u32 vlan, bool vlvf_bypass);\n \n+void ngbe_set_mac_anti_spoofing(struct ngbe_hw *hw, bool enable, int vf);\n+void ngbe_set_vlan_anti_spoofing(struct ngbe_hw *hw, bool enable, int vf);\n s32 ngbe_init_thermal_sensor_thresh(struct ngbe_hw *hw);\n s32 ngbe_mac_check_overtemp(struct ngbe_hw *hw);\n void ngbe_disable_rx(struct ngbe_hw *hw);\ndiff --git a/drivers/net/ngbe/base/ngbe_mbx.c b/drivers/net/ngbe/base/ngbe_mbx.c\nindex 1ac9531ceb..764ae81319 100644\n--- a/drivers/net/ngbe/base/ngbe_mbx.c\n+++ b/drivers/net/ngbe/base/ngbe_mbx.c\n@@ -7,6 +7,303 @@\n \n #include \"ngbe_mbx.h\"\n \n+/**\n+ *  ngbe_read_mbx - Reads a message from the mailbox\n+ *  @hw: pointer to the HW structure\n+ *  @msg: The message buffer\n+ *  @size: Length of buffer\n+ *  @mbx_id: id of mailbox to read\n+ *\n+ *  returns 0 if it successfully read message from buffer\n+ **/\n+s32 ngbe_read_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)\n+{\n+\tstruct ngbe_mbx_info *mbx = &hw->mbx;\n+\ts32 ret_val = NGBE_ERR_MBX;\n+\n+\tDEBUGFUNC(\"ngbe_read_mbx\");\n+\n+\t/* limit read to size of mailbox */\n+\tif (size > mbx->size)\n+\t\tsize = mbx->size;\n+\n+\tif (mbx->read)\n+\t\tret_val = mbx->read(hw, msg, size, mbx_id);\n+\n+\treturn ret_val;\n+}\n+\n+/**\n+ *  ngbe_write_mbx - Write a message to the mailbox\n+ *  @hw: pointer to the HW structure\n+ *  @msg: The message buffer\n+ *  @size: Length of buffer\n+ *  @mbx_id: id of mailbox to write\n+ *\n+ *  returns 0 if it successfully copied message into the buffer\n+ **/\n+s32 ngbe_write_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)\n+{\n+\tstruct ngbe_mbx_info *mbx = &hw->mbx;\n+\ts32 ret_val = 0;\n+\n+\tDEBUGFUNC(\"ngbe_write_mbx\");\n+\n+\tif (size > mbx->size) {\n+\t\tret_val = NGBE_ERR_MBX;\n+\t\tDEBUGOUT(\"Invalid mailbox message size %d\", size);\n+\t} else if (mbx->write) {\n+\t\tret_val = mbx->write(hw, msg, size, mbx_id);\n+\t}\n+\n+\treturn ret_val;\n+}\n+\n+/**\n+ *  ngbe_check_for_msg - checks to see if someone sent us mail\n+ *  @hw: pointer to the HW structure\n+ *  @mbx_id: id of mailbox to check\n+ *\n+ *  returns 0 if the Status bit was found or else ERR_MBX\n+ **/\n+s32 ngbe_check_for_msg(struct ngbe_hw *hw, u16 mbx_id)\n+{\n+\tstruct ngbe_mbx_info *mbx = &hw->mbx;\n+\ts32 ret_val = NGBE_ERR_MBX;\n+\n+\tDEBUGFUNC(\"ngbe_check_for_msg\");\n+\n+\tif (mbx->check_for_msg)\n+\t\tret_val = mbx->check_for_msg(hw, mbx_id);\n+\n+\treturn ret_val;\n+}\n+\n+/**\n+ *  ngbe_check_for_ack - checks to see if someone sent us ACK\n+ *  @hw: pointer to the HW structure\n+ *  @mbx_id: id of mailbox to check\n+ *\n+ *  returns 0 if the Status bit was found or else ERR_MBX\n+ **/\n+s32 ngbe_check_for_ack(struct ngbe_hw *hw, u16 mbx_id)\n+{\n+\tstruct ngbe_mbx_info *mbx = &hw->mbx;\n+\ts32 ret_val = NGBE_ERR_MBX;\n+\n+\tDEBUGFUNC(\"ngbe_check_for_ack\");\n+\n+\tif (mbx->check_for_ack)\n+\t\tret_val = mbx->check_for_ack(hw, mbx_id);\n+\n+\treturn ret_val;\n+}\n+\n+/**\n+ *  ngbe_check_for_rst - checks to see if other side has reset\n+ *  @hw: pointer to the HW structure\n+ *  @mbx_id: id of mailbox to check\n+ *\n+ *  returns 0 if the Status bit was found or else ERR_MBX\n+ **/\n+s32 ngbe_check_for_rst(struct ngbe_hw *hw, u16 mbx_id)\n+{\n+\tstruct ngbe_mbx_info *mbx = &hw->mbx;\n+\ts32 ret_val = NGBE_ERR_MBX;\n+\n+\tDEBUGFUNC(\"ngbe_check_for_rst\");\n+\n+\tif (mbx->check_for_rst)\n+\t\tret_val = mbx->check_for_rst(hw, mbx_id);\n+\n+\treturn ret_val;\n+}\n+\n+STATIC s32 ngbe_check_for_bit_pf(struct ngbe_hw *hw, u32 mask)\n+{\n+\tu32 mbvficr = rd32(hw, NGBE_MBVFICR);\n+\ts32 ret_val = NGBE_ERR_MBX;\n+\n+\tif (mbvficr & mask) {\n+\t\tret_val = 0;\n+\t\twr32(hw, NGBE_MBVFICR, mask);\n+\t}\n+\n+\treturn ret_val;\n+}\n+\n+/**\n+ *  ngbe_check_for_msg_pf - checks to see if the VF has sent mail\n+ *  @hw: pointer to the HW structure\n+ *  @vf_number: the VF index\n+ *\n+ *  returns 0 if the VF has set the Status bit or else ERR_MBX\n+ **/\n+s32 ngbe_check_for_msg_pf(struct ngbe_hw *hw, u16 vf_number)\n+{\n+\ts32 ret_val = NGBE_ERR_MBX;\n+\tu32 vf_bit = vf_number;\n+\n+\tDEBUGFUNC(\"ngbe_check_for_msg_pf\");\n+\n+\tif (!ngbe_check_for_bit_pf(hw, NGBE_MBVFICR_VFREQ_VF1 << vf_bit)) {\n+\t\tret_val = 0;\n+\t\thw->mbx.stats.reqs++;\n+\t}\n+\n+\treturn ret_val;\n+}\n+\n+/**\n+ *  ngbe_check_for_ack_pf - checks to see if the VF has ACKed\n+ *  @hw: pointer to the HW structure\n+ *  @vf_number: the VF index\n+ *\n+ *  returns 0 if the VF has set the Status bit or else ERR_MBX\n+ **/\n+s32 ngbe_check_for_ack_pf(struct ngbe_hw *hw, u16 vf_number)\n+{\n+\ts32 ret_val = NGBE_ERR_MBX;\n+\tu32 vf_bit = vf_number;\n+\n+\tDEBUGFUNC(\"ngbe_check_for_ack_pf\");\n+\n+\tif (!ngbe_check_for_bit_pf(hw, NGBE_MBVFICR_VFACK_VF1 << vf_bit)) {\n+\t\tret_val = 0;\n+\t\thw->mbx.stats.acks++;\n+\t}\n+\n+\treturn ret_val;\n+}\n+\n+/**\n+ *  ngbe_check_for_rst_pf - checks to see if the VF has reset\n+ *  @hw: pointer to the HW structure\n+ *  @vf_number: the VF index\n+ *\n+ *  returns 0 if the VF has set the Status bit or else ERR_MBX\n+ **/\n+s32 ngbe_check_for_rst_pf(struct ngbe_hw *hw, u16 vf_number)\n+{\n+\tu32 vflre = 0;\n+\ts32 ret_val = NGBE_ERR_MBX;\n+\n+\tDEBUGFUNC(\"ngbe_check_for_rst_pf\");\n+\n+\tvflre = rd32(hw, NGBE_FLRVFE);\n+\tif (vflre & (1 << vf_number)) {\n+\t\tret_val = 0;\n+\t\twr32(hw, NGBE_FLRVFEC, (1 << vf_number));\n+\t\thw->mbx.stats.rsts++;\n+\t}\n+\n+\treturn ret_val;\n+}\n+\n+/**\n+ *  ngbe_obtain_mbx_lock_pf - obtain mailbox lock\n+ *  @hw: pointer to the HW structure\n+ *  @vf_number: the VF index\n+ *\n+ *  return 0 if we obtained the mailbox lock\n+ **/\n+STATIC s32 ngbe_obtain_mbx_lock_pf(struct ngbe_hw *hw, u16 vf_number)\n+{\n+\ts32 ret_val = NGBE_ERR_MBX;\n+\tu32 p2v_mailbox;\n+\n+\tDEBUGFUNC(\"ngbe_obtain_mbx_lock_pf\");\n+\n+\t/* Take ownership of the buffer */\n+\twr32(hw, NGBE_MBCTL(vf_number), NGBE_MBCTL_PFU);\n+\n+\t/* reserve mailbox for vf use */\n+\tp2v_mailbox = rd32(hw, NGBE_MBCTL(vf_number));\n+\tif (p2v_mailbox & NGBE_MBCTL_PFU)\n+\t\tret_val = 0;\n+\telse\n+\t\tDEBUGOUT(\"Failed to obtain mailbox lock for VF%d\", vf_number);\n+\n+\n+\treturn ret_val;\n+}\n+\n+/**\n+ *  ngbe_write_mbx_pf - Places a message in the mailbox\n+ *  @hw: pointer to the HW structure\n+ *  @msg: The message buffer\n+ *  @size: Length of buffer\n+ *  @vf_number: the VF index\n+ *\n+ *  returns 0 if it successfully copied message into the buffer\n+ **/\n+s32 ngbe_write_mbx_pf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number)\n+{\n+\ts32 ret_val;\n+\tu16 i;\n+\n+\tDEBUGFUNC(\"ngbe_write_mbx_pf\");\n+\n+\t/* lock the mailbox to prevent pf/vf race condition */\n+\tret_val = ngbe_obtain_mbx_lock_pf(hw, vf_number);\n+\tif (ret_val)\n+\t\tgoto out_no_write;\n+\n+\t/* flush msg and acks as we are overwriting the message buffer */\n+\tngbe_check_for_msg_pf(hw, vf_number);\n+\tngbe_check_for_ack_pf(hw, vf_number);\n+\n+\t/* copy the caller specified message to the mailbox memory buffer */\n+\tfor (i = 0; i < size; i++)\n+\t\twr32a(hw, NGBE_MBMEM(vf_number), i, msg[i]);\n+\n+\t/* Interrupt VF to tell it a message has been sent and release buffer*/\n+\twr32(hw, NGBE_MBCTL(vf_number), NGBE_MBCTL_STS);\n+\n+\t/* update stats */\n+\thw->mbx.stats.msgs_tx++;\n+\n+out_no_write:\n+\treturn ret_val;\n+}\n+\n+/**\n+ *  ngbe_read_mbx_pf - Read a message from the mailbox\n+ *  @hw: pointer to the HW structure\n+ *  @msg: The message buffer\n+ *  @size: Length of buffer\n+ *  @vf_number: the VF index\n+ *\n+ *  This function copies a message from the mailbox buffer to the caller's\n+ *  memory buffer.  The presumption is that the caller knows that there was\n+ *  a message due to a VF request so no polling for message is needed.\n+ **/\n+s32 ngbe_read_mbx_pf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number)\n+{\n+\ts32 ret_val;\n+\tu16 i;\n+\n+\tDEBUGFUNC(\"ngbe_read_mbx_pf\");\n+\n+\t/* lock the mailbox to prevent pf/vf race condition */\n+\tret_val = ngbe_obtain_mbx_lock_pf(hw, vf_number);\n+\tif (ret_val)\n+\t\tgoto out_no_read;\n+\n+\t/* copy the message to the mailbox memory buffer */\n+\tfor (i = 0; i < size; i++)\n+\t\tmsg[i] = rd32a(hw, NGBE_MBMEM(vf_number), i);\n+\n+\t/* Acknowledge the message and release buffer */\n+\twr32(hw, NGBE_MBCTL(vf_number), NGBE_MBCTL_ACK);\n+\n+\t/* update stats */\n+\thw->mbx.stats.msgs_rx++;\n+\n+out_no_read:\n+\treturn ret_val;\n+}\n+\n /**\n  *  ngbe_init_mbx_params_pf - set initial values for pf mailbox\n  *  @hw: pointer to the HW structure\ndiff --git a/drivers/net/ngbe/base/ngbe_mbx.h b/drivers/net/ngbe/base/ngbe_mbx.h\nindex d280945baf..d47da2718c 100644\n--- a/drivers/net/ngbe/base/ngbe_mbx.h\n+++ b/drivers/net/ngbe/base/ngbe_mbx.h\n@@ -6,6 +6,84 @@\n #ifndef _NGBE_MBX_H_\n #define _NGBE_MBX_H_\n \n+#define NGBE_ERR_MBX\t\t-100\n+\n+/* If it's a NGBE_VF_* msg then it originates in the VF and is sent to the\n+ * PF.  The reverse is true if it is NGBE_PF_*.\n+ * Message ACK's are the value or'd with 0xF0000000\n+ */\n+/* Messages below or'd with this are the ACK */\n+#define NGBE_VT_MSGTYPE_ACK\t0x80000000\n+/* Messages below or'd with this are the NACK */\n+#define NGBE_VT_MSGTYPE_NACK\t0x40000000\n+/* Indicates that VF is still clear to send requests */\n+#define NGBE_VT_MSGTYPE_CTS\t0x20000000\n+\n+#define NGBE_VT_MSGINFO_SHIFT\t16\n+/* bits 23:16 are used for extra info for certain messages */\n+#define NGBE_VT_MSGINFO_MASK\t(0xFF << NGBE_VT_MSGINFO_SHIFT)\n+\n+/*\n+ * each element denotes a version of the API; existing numbers may not\n+ * change; any additions must go at the end\n+ */\n+enum ngbe_pfvf_api_rev {\n+\tngbe_mbox_api_null,\n+\tngbe_mbox_api_10,\t/* API version 1.0, linux/freebsd VF driver */\n+\tngbe_mbox_api_11,\t/* API version 1.1, linux/freebsd VF driver */\n+\tngbe_mbox_api_12,\t/* API version 1.2, linux/freebsd VF driver */\n+\tngbe_mbox_api_13,\t/* API version 1.3, linux/freebsd VF driver */\n+\tngbe_mbox_api_20,\t/* API version 2.0, solaris Phase1 VF driver */\n+\t/* This value should always be last */\n+\tngbe_mbox_api_unknown,\t/* indicates that API version is not known */\n+};\n+\n+/* mailbox API, legacy requests */\n+#define NGBE_VF_RESET\t\t0x01 /* VF requests reset */\n+#define NGBE_VF_SET_MAC_ADDR\t0x02 /* VF requests PF to set MAC addr */\n+#define NGBE_VF_SET_MULTICAST\t0x03 /* VF requests PF to set MC addr */\n+#define NGBE_VF_SET_VLAN\t0x04 /* VF requests PF to set VLAN */\n+\n+/* mailbox API, version 1.0 VF requests */\n+#define NGBE_VF_SET_LPE\t0x05 /* VF requests PF to set VMOLR.LPE */\n+#define NGBE_VF_SET_MACVLAN\t0x06 /* VF requests PF for unicast filter */\n+#define NGBE_VF_API_NEGOTIATE\t0x08 /* negotiate API version */\n+\n+/* mailbox API, version 1.1 VF requests */\n+#define NGBE_VF_GET_QUEUES\t0x09 /* get queue configuration */\n+\n+/* mailbox API, version 1.2 VF requests */\n+#define NGBE_VF_GET_RETA      0x0a    /* VF request for RETA */\n+#define NGBE_VF_GET_RSS_KEY\t0x0b    /* get RSS key */\n+#define NGBE_VF_UPDATE_XCAST_MODE\t0x0c\n+\n+/* mode choices for NGBE_VF_UPDATE_XCAST_MODE */\n+enum ngbevf_xcast_modes {\n+\tNGBEVF_XCAST_MODE_NONE = 0,\n+\tNGBEVF_XCAST_MODE_MULTI,\n+\tNGBEVF_XCAST_MODE_ALLMULTI,\n+\tNGBEVF_XCAST_MODE_PROMISC,\n+};\n+\n+/* GET_QUEUES return data indices within the mailbox */\n+#define NGBE_VF_TX_QUEUES\t1\t/* number of Tx queues supported */\n+#define NGBE_VF_RX_QUEUES\t2\t/* number of Rx queues supported */\n+#define NGBE_VF_TRANS_VLAN\t3\t/* Indication of port vlan */\n+#define NGBE_VF_DEF_QUEUE\t4\t/* Default queue offset */\n+\n+/* length of permanent address message returned from PF */\n+#define NGBE_VF_PERMADDR_MSG_LEN\t4\n+s32 ngbe_read_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);\n+s32 ngbe_write_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);\n+s32 ngbe_check_for_msg(struct ngbe_hw *hw, u16 mbx_id);\n+s32 ngbe_check_for_ack(struct ngbe_hw *hw, u16 mbx_id);\n+s32 ngbe_check_for_rst(struct ngbe_hw *hw, u16 mbx_id);\n void ngbe_init_mbx_params_pf(struct ngbe_hw *hw);\n \n+s32 ngbe_read_mbx_pf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);\n+s32 ngbe_write_mbx_pf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);\n+s32 ngbe_check_for_msg_pf(struct ngbe_hw *hw, u16 vf_number);\n+s32 ngbe_check_for_ack_pf(struct ngbe_hw *hw, u16 vf_number);\n+s32 ngbe_check_for_rst_pf(struct ngbe_hw *hw, u16 vf_number);\n+\n #endif /* _NGBE_MBX_H_ */\ndiff --git a/drivers/net/ngbe/base/ngbe_type.h b/drivers/net/ngbe/base/ngbe_type.h\nindex bc95fcf609..7a85f82abd 100644\n--- a/drivers/net/ngbe/base/ngbe_type.h\n+++ b/drivers/net/ngbe/base/ngbe_type.h\n@@ -254,6 +254,11 @@ struct ngbe_mac_info {\n \t\t\t\t      u32 mc_addr_count,\n \t\t\t\t      ngbe_mc_addr_itr func, bool clear);\n \ts32 (*clear_vfta)(struct ngbe_hw *hw);\n+\ts32 (*set_vfta)(struct ngbe_hw *hw, u32 vlan,\n+\t\t\t u32 vind, bool vlan_on, bool vlvf_bypass);\n+\ts32 (*set_vlvf)(struct ngbe_hw *hw, u32 vlan, u32 vind,\n+\t\t\t   bool vlan_on, u32 *vfta_delta, u32 vfta,\n+\t\t\t   bool vlvf_bypass);\n \tvoid (*set_mac_anti_spoofing)(struct ngbe_hw *hw, bool enable, int vf);\n \tvoid (*set_vlan_anti_spoofing)(struct ngbe_hw *hw,\n \t\t\t\t\tbool enable, int vf);\n@@ -319,6 +324,11 @@ struct ngbe_mbx_stats {\n \n struct ngbe_mbx_info {\n \tvoid (*init_params)(struct ngbe_hw *hw);\n+\ts32  (*read)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);\n+\ts32  (*write)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);\n+\ts32  (*check_for_msg)(struct ngbe_hw *hw, u16 mbx_id);\n+\ts32  (*check_for_ack)(struct ngbe_hw *hw, u16 mbx_id);\n+\ts32  (*check_for_rst)(struct ngbe_hw *hw, u16 mbx_id);\n \n \tstruct ngbe_mbx_stats stats;\n \tu32 timeout;\ndiff --git a/drivers/net/ngbe/meson.build b/drivers/net/ngbe/meson.build\nindex 8b5195aab3..b276ec3341 100644\n--- a/drivers/net/ngbe/meson.build\n+++ b/drivers/net/ngbe/meson.build\n@@ -20,3 +20,5 @@ sources = files(\n deps += ['hash']\n \n includes += include_directories('base')\n+\n+install_headers('rte_pmd_ngbe.h')\ndiff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c\nindex 70e471b2c2..52d7b6376d 100644\n--- a/drivers/net/ngbe/ngbe_ethdev.c\n+++ b/drivers/net/ngbe/ngbe_ethdev.c\n@@ -2123,6 +2123,11 @@ ngbe_dev_interrupt_action(struct rte_eth_dev *dev)\n \n \tPMD_DRV_LOG(DEBUG, \"intr action type %d\", intr->flags);\n \n+\tif (intr->flags & NGBE_FLAG_MAILBOX) {\n+\t\tngbe_pf_mbx_process(dev);\n+\t\tintr->flags &= ~NGBE_FLAG_MAILBOX;\n+\t}\n+\n \tif (intr->flags & NGBE_FLAG_NEED_LINK_UPDATE) {\n \t\tstruct rte_eth_link link;\n \n@@ -2183,6 +2188,8 @@ ngbe_dev_interrupt_delayed_handler(void *param)\n \tngbe_disable_intr(hw);\n \n \teicr = ((u32 *)hw->isb_mem)[NGBE_ISB_MISC];\n+\tif (eicr & NGBE_ICRMISC_VFMBX)\n+\t\tngbe_pf_mbx_process(dev);\n \n \tif (intr->flags & NGBE_FLAG_NEED_LINK_UPDATE) {\n \t\tngbe_dev_link_update(dev, 0);\ndiff --git a/drivers/net/ngbe/ngbe_ethdev.h b/drivers/net/ngbe/ngbe_ethdev.h\nindex f5a1363d10..26911cc7d2 100644\n--- a/drivers/net/ngbe/ngbe_ethdev.h\n+++ b/drivers/net/ngbe/ngbe_ethdev.h\n@@ -71,6 +71,11 @@ struct ngbe_hwstrip {\n \tuint32_t bitmap[NGBE_HWSTRIP_BITMAP_SIZE];\n };\n \n+/*\n+ * VF data which used by PF host only\n+ */\n+#define NGBE_MAX_VF_MC_ENTRIES      30\n+\n struct ngbe_uta_info {\n \tuint8_t  uc_filter_type;\n \tuint16_t uta_in_use;\n@@ -79,8 +84,14 @@ struct ngbe_uta_info {\n \n struct ngbe_vf_info {\n \tuint8_t vf_mac_addresses[RTE_ETHER_ADDR_LEN];\n+\tuint16_t vf_mc_hashes[NGBE_MAX_VF_MC_ENTRIES];\n+\tuint16_t num_vf_mc_hashes;\n \tbool clear_to_send;\n+\tuint16_t vlan_count;\n+\tuint8_t api_version;\n \tuint16_t switch_domain_id;\n+\tuint16_t xcast_mode;\n+\tuint16_t mac_count;\n };\n \n /*\n@@ -233,6 +244,8 @@ int ngbe_pf_host_init(struct rte_eth_dev *eth_dev);\n \n void ngbe_pf_host_uninit(struct rte_eth_dev *eth_dev);\n \n+void ngbe_pf_mbx_process(struct rte_eth_dev *eth_dev);\n+\n int ngbe_pf_host_configure(struct rte_eth_dev *eth_dev);\n \n #define NGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */\ndiff --git a/drivers/net/ngbe/ngbe_pf.c b/drivers/net/ngbe/ngbe_pf.c\nindex 2f9dfc4284..550f5d556b 100644\n--- a/drivers/net/ngbe/ngbe_pf.c\n+++ b/drivers/net/ngbe/ngbe_pf.c\n@@ -10,8 +10,11 @@\n \n #include \"base/ngbe.h\"\n #include \"ngbe_ethdev.h\"\n+#include \"rte_pmd_ngbe.h\"\n \n #define NGBE_MAX_VFTA     (128)\n+#define NGBE_VF_MSG_SIZE_DEFAULT 1\n+#define NGBE_VF_GET_QUEUE_MSG_SIZE 5\n \n static inline uint16_t\n dev_num_vf(struct rte_eth_dev *eth_dev)\n@@ -39,6 +42,16 @@ int ngbe_vf_perm_addr_gen(struct rte_eth_dev *dev, uint16_t vf_num)\n \treturn 0;\n }\n \n+static inline int\n+ngbe_mb_intr_setup(struct rte_eth_dev *dev)\n+{\n+\tstruct ngbe_interrupt *intr = ngbe_dev_intr(dev);\n+\n+\tintr->mask_misc |= NGBE_ICRMISC_VFMBX;\n+\n+\treturn 0;\n+}\n+\n int ngbe_pf_host_init(struct rte_eth_dev *eth_dev)\n {\n \tstruct ngbe_vf_info **vfinfo = NGBE_DEV_VFDATA(eth_dev);\n@@ -85,6 +98,9 @@ int ngbe_pf_host_init(struct rte_eth_dev *eth_dev)\n \t/* init_mailbox_params */\n \thw->mbx.init_params(hw);\n \n+\t/* set mb interrupt mask */\n+\tngbe_mb_intr_setup(eth_dev);\n+\n \treturn ret;\n }\n \n@@ -194,3 +210,551 @@ int ngbe_pf_host_configure(struct rte_eth_dev *eth_dev)\n \treturn 0;\n }\n \n+static void\n+ngbe_set_rx_mode(struct rte_eth_dev *eth_dev)\n+{\n+\tstruct rte_eth_dev_data *dev_data = eth_dev->data;\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(eth_dev);\n+\tu32 fctrl, vmolr;\n+\tuint16_t vfn = dev_num_vf(eth_dev);\n+\n+\t/* disable store-bad-packets */\n+\twr32m(hw, NGBE_SECRXCTL, NGBE_SECRXCTL_SAVEBAD, 0);\n+\n+\t/* Check for Promiscuous and All Multicast modes */\n+\tfctrl = rd32m(hw, NGBE_PSRCTL,\n+\t\t\t~(NGBE_PSRCTL_UCP | NGBE_PSRCTL_MCP));\n+\tfctrl |= NGBE_PSRCTL_BCA |\n+\t\t NGBE_PSRCTL_MCHFENA;\n+\n+\tvmolr = rd32m(hw, NGBE_POOLETHCTL(vfn),\n+\t\t\t~(NGBE_POOLETHCTL_UCP |\n+\t\t\t  NGBE_POOLETHCTL_MCP |\n+\t\t\t  NGBE_POOLETHCTL_UCHA |\n+\t\t\t  NGBE_POOLETHCTL_MCHA));\n+\tvmolr |= NGBE_POOLETHCTL_BCA |\n+\t\t NGBE_POOLETHCTL_UTA |\n+\t\t NGBE_POOLETHCTL_VLA;\n+\n+\tif (dev_data->promiscuous) {\n+\t\tfctrl |= NGBE_PSRCTL_UCP |\n+\t\t\t NGBE_PSRCTL_MCP;\n+\t\t/* pf don't want packets routing to vf, so clear UPE */\n+\t\tvmolr |= NGBE_POOLETHCTL_MCP;\n+\t} else if (dev_data->all_multicast) {\n+\t\tfctrl |= NGBE_PSRCTL_MCP;\n+\t\tvmolr |= NGBE_POOLETHCTL_MCP;\n+\t} else {\n+\t\tvmolr |= NGBE_POOLETHCTL_UCHA;\n+\t\tvmolr |= NGBE_POOLETHCTL_MCHA;\n+\t}\n+\n+\twr32(hw, NGBE_POOLETHCTL(vfn), vmolr);\n+\n+\twr32(hw, NGBE_PSRCTL, fctrl);\n+\n+\tngbe_vlan_hw_strip_config(eth_dev);\n+}\n+\n+static inline void\n+ngbe_vf_reset_event(struct rte_eth_dev *eth_dev, uint16_t vf)\n+{\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(eth_dev);\n+\tstruct ngbe_vf_info *vfinfo = *(NGBE_DEV_VFDATA(eth_dev));\n+\tint rar_entry = hw->mac.num_rar_entries - (vf + 1);\n+\tuint32_t vmolr = rd32(hw, NGBE_POOLETHCTL(vf));\n+\n+\tvmolr |= (NGBE_POOLETHCTL_UCHA |\n+\t\t\tNGBE_POOLETHCTL_BCA | NGBE_POOLETHCTL_UTA);\n+\twr32(hw, NGBE_POOLETHCTL(vf), vmolr);\n+\n+\twr32(hw, NGBE_POOLTAG(vf), 0);\n+\n+\t/* reset multicast table array for vf */\n+\tvfinfo[vf].num_vf_mc_hashes = 0;\n+\n+\t/* reset rx mode */\n+\tngbe_set_rx_mode(eth_dev);\n+\n+\thw->mac.clear_rar(hw, rar_entry);\n+}\n+\n+static inline void\n+ngbe_vf_reset_msg(struct rte_eth_dev *eth_dev, uint16_t vf)\n+{\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(eth_dev);\n+\tuint32_t reg;\n+\tuint32_t vf_shift;\n+\tconst uint8_t VFRE_SHIFT = 5;  /* VFRE 32 bits per slot */\n+\tconst uint8_t VFRE_MASK = (uint8_t)((1U << VFRE_SHIFT) - 1);\n+\tuint8_t  nb_q_per_pool;\n+\tint i;\n+\n+\tvf_shift = vf & VFRE_MASK;\n+\n+\t/* enable transmit for vf */\n+\treg = rd32(hw, NGBE_POOLTXENA(0));\n+\treg |= (1 << vf_shift);\n+\twr32(hw, NGBE_POOLTXENA(0), reg);\n+\n+\t/* enable all queue drop for IOV */\n+\tnb_q_per_pool = RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool;\n+\tfor (i = vf * nb_q_per_pool; i < (vf + 1) * nb_q_per_pool; i++) {\n+\t\tngbe_flush(hw);\n+\t\treg = 1 << (i % 32);\n+\t\twr32m(hw, NGBE_QPRXDROP, reg, reg);\n+\t}\n+\n+\t/* enable receive for vf */\n+\treg = rd32(hw, NGBE_POOLRXENA(0));\n+\treg |= (reg | (1 << vf_shift));\n+\twr32(hw, NGBE_POOLRXENA(0), reg);\n+\n+\tngbe_vf_reset_event(eth_dev, vf);\n+}\n+\n+static int\n+ngbe_disable_vf_mc_promisc(struct rte_eth_dev *eth_dev, uint32_t vf)\n+{\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(eth_dev);\n+\tuint32_t vmolr;\n+\n+\tvmolr = rd32(hw, NGBE_POOLETHCTL(vf));\n+\n+\tPMD_DRV_LOG(INFO, \"VF %u: disabling multicast promiscuous\\n\", vf);\n+\n+\tvmolr &= ~NGBE_POOLETHCTL_MCP;\n+\n+\twr32(hw, NGBE_POOLETHCTL(vf), vmolr);\n+\n+\treturn 0;\n+}\n+\n+static int\n+ngbe_vf_reset(struct rte_eth_dev *eth_dev, uint16_t vf, uint32_t *msgbuf)\n+{\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(eth_dev);\n+\tstruct ngbe_vf_info *vfinfo = *(NGBE_DEV_VFDATA(eth_dev));\n+\tunsigned char *vf_mac = vfinfo[vf].vf_mac_addresses;\n+\tint rar_entry = hw->mac.num_rar_entries - (vf + 1);\n+\tuint8_t *new_mac = (uint8_t *)(&msgbuf[1]);\n+\n+\tngbe_vf_reset_msg(eth_dev, vf);\n+\n+\thw->mac.set_rar(hw, rar_entry, vf_mac, vf, true);\n+\n+\t/* Disable multicast promiscuous at reset */\n+\tngbe_disable_vf_mc_promisc(eth_dev, vf);\n+\n+\t/* reply to reset with ack and vf mac address */\n+\tmsgbuf[0] = NGBE_VF_RESET | NGBE_VT_MSGTYPE_ACK;\n+\trte_memcpy(new_mac, vf_mac, RTE_ETHER_ADDR_LEN);\n+\t/*\n+\t * Piggyback the multicast filter type so VF can compute the\n+\t * correct vectors\n+\t */\n+\tmsgbuf[3] = hw->mac.mc_filter_type;\n+\tngbe_write_mbx(hw, msgbuf, NGBE_VF_PERMADDR_MSG_LEN, vf);\n+\n+\treturn 0;\n+}\n+\n+static int\n+ngbe_vf_set_mac_addr(struct rte_eth_dev *eth_dev,\n+\t\tuint32_t vf, uint32_t *msgbuf)\n+{\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(eth_dev);\n+\tstruct ngbe_vf_info *vfinfo = *(NGBE_DEV_VFDATA(eth_dev));\n+\tint rar_entry = hw->mac.num_rar_entries - (vf + 1);\n+\tuint8_t *new_mac = (uint8_t *)(&msgbuf[1]);\n+\tstruct rte_ether_addr *ea = (struct rte_ether_addr *)new_mac;\n+\n+\tif (rte_is_valid_assigned_ether_addr(ea)) {\n+\t\trte_memcpy(vfinfo[vf].vf_mac_addresses, new_mac, 6);\n+\t\treturn hw->mac.set_rar(hw, rar_entry, new_mac, vf, true);\n+\t}\n+\treturn -1;\n+}\n+\n+static int\n+ngbe_vf_set_multicast(struct rte_eth_dev *eth_dev,\n+\t\tuint32_t vf, uint32_t *msgbuf)\n+{\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(eth_dev);\n+\tstruct ngbe_vf_info *vfinfo = *(NGBE_DEV_VFDATA(eth_dev));\n+\tint nb_entries = (msgbuf[0] & NGBE_VT_MSGINFO_MASK) >>\n+\t\tNGBE_VT_MSGINFO_SHIFT;\n+\tuint16_t *hash_list = (uint16_t *)&msgbuf[1];\n+\tuint32_t mta_idx;\n+\tuint32_t mta_shift;\n+\tconst uint32_t NGBE_MTA_INDEX_MASK = 0x7F;\n+\tconst uint32_t NGBE_MTA_BIT_SHIFT = 5;\n+\tconst uint32_t NGBE_MTA_BIT_MASK = (0x1 << NGBE_MTA_BIT_SHIFT) - 1;\n+\tuint32_t reg_val;\n+\tint i;\n+\tu32 vmolr = rd32(hw, NGBE_POOLETHCTL(vf));\n+\n+\t/* Disable multicast promiscuous first */\n+\tngbe_disable_vf_mc_promisc(eth_dev, vf);\n+\n+\t/* only so many hash values supported */\n+\tnb_entries = RTE_MIN(nb_entries, NGBE_MAX_VF_MC_ENTRIES);\n+\n+\t/* store the mc entries  */\n+\tvfinfo->num_vf_mc_hashes = (uint16_t)nb_entries;\n+\tfor (i = 0; i < nb_entries; i++)\n+\t\tvfinfo->vf_mc_hashes[i] = hash_list[i];\n+\n+\tif (nb_entries == 0) {\n+\t\tvmolr &= ~NGBE_POOLETHCTL_MCHA;\n+\t\twr32(hw, NGBE_POOLETHCTL(vf), vmolr);\n+\t\treturn 0;\n+\t}\n+\n+\tfor (i = 0; i < vfinfo->num_vf_mc_hashes; i++) {\n+\t\tmta_idx = (vfinfo->vf_mc_hashes[i] >> NGBE_MTA_BIT_SHIFT)\n+\t\t\t\t& NGBE_MTA_INDEX_MASK;\n+\t\tmta_shift = vfinfo->vf_mc_hashes[i] & NGBE_MTA_BIT_MASK;\n+\t\treg_val = rd32(hw, NGBE_MCADDRTBL(mta_idx));\n+\t\treg_val |= (1 << mta_shift);\n+\t\twr32(hw, NGBE_MCADDRTBL(mta_idx), reg_val);\n+\t}\n+\n+\tvmolr |= NGBE_POOLETHCTL_MCHA;\n+\twr32(hw, NGBE_POOLETHCTL(vf), vmolr);\n+\n+\treturn 0;\n+}\n+\n+static int\n+ngbe_vf_set_vlan(struct rte_eth_dev *eth_dev, uint32_t vf, uint32_t *msgbuf)\n+{\n+\tint add, vid;\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(eth_dev);\n+\tstruct ngbe_vf_info *vfinfo = *(NGBE_DEV_VFDATA(eth_dev));\n+\n+\tadd = (msgbuf[0] & NGBE_VT_MSGINFO_MASK)\n+\t\t>> NGBE_VT_MSGINFO_SHIFT;\n+\tvid = NGBE_PSRVLAN_VID(msgbuf[1]);\n+\n+\tif (add)\n+\t\tvfinfo[vf].vlan_count++;\n+\telse if (vfinfo[vf].vlan_count)\n+\t\tvfinfo[vf].vlan_count--;\n+\treturn hw->mac.set_vfta(hw, vid, vf, (bool)add, false);\n+}\n+\n+static int\n+ngbe_set_vf_lpe(struct rte_eth_dev *eth_dev,\n+\t\t__rte_unused uint32_t vf, uint32_t *msgbuf)\n+{\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(eth_dev);\n+\tuint32_t max_frame = msgbuf[1];\n+\tuint32_t max_frs;\n+\n+\tif (max_frame < RTE_ETHER_MIN_LEN ||\n+\t\t\tmax_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)\n+\t\treturn -1;\n+\n+\tmax_frs = rd32m(hw, NGBE_FRMSZ, NGBE_FRMSZ_MAX_MASK);\n+\tif (max_frs < max_frame) {\n+\t\twr32m(hw, NGBE_FRMSZ, NGBE_FRMSZ_MAX_MASK,\n+\t\t\tNGBE_FRMSZ_MAX(max_frame));\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+ngbe_negotiate_vf_api(struct rte_eth_dev *eth_dev,\n+\t\tuint32_t vf, uint32_t *msgbuf)\n+{\n+\tuint32_t api_version = msgbuf[1];\n+\tstruct ngbe_vf_info *vfinfo = *NGBE_DEV_VFDATA(eth_dev);\n+\n+\tswitch (api_version) {\n+\tcase ngbe_mbox_api_10:\n+\tcase ngbe_mbox_api_11:\n+\tcase ngbe_mbox_api_12:\n+\tcase ngbe_mbox_api_13:\n+\t\tvfinfo[vf].api_version = (uint8_t)api_version;\n+\t\treturn 0;\n+\tdefault:\n+\t\tbreak;\n+\t}\n+\n+\tPMD_DRV_LOG(ERR, \"Negotiate invalid api version %u from VF %d\\n\",\n+\t\tapi_version, vf);\n+\n+\treturn -1;\n+}\n+\n+static int\n+ngbe_get_vf_queues(struct rte_eth_dev *eth_dev, uint32_t vf, uint32_t *msgbuf)\n+{\n+\tstruct ngbe_vf_info *vfinfo = *NGBE_DEV_VFDATA(eth_dev);\n+\tuint32_t default_q = 0;\n+\n+\t/* Verify if the PF supports the mbox APIs version or not */\n+\tswitch (vfinfo[vf].api_version) {\n+\tcase ngbe_mbox_api_20:\n+\tcase ngbe_mbox_api_11:\n+\tcase ngbe_mbox_api_12:\n+\tcase ngbe_mbox_api_13:\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -1;\n+\t}\n+\n+\t/* Notify VF of Rx and Tx queue number */\n+\tmsgbuf[NGBE_VF_RX_QUEUES] = RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool;\n+\tmsgbuf[NGBE_VF_TX_QUEUES] = RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool;\n+\n+\t/* Notify VF of default queue */\n+\tmsgbuf[NGBE_VF_DEF_QUEUE] = default_q;\n+\n+\tmsgbuf[NGBE_VF_TRANS_VLAN] = 0;\n+\n+\treturn 0;\n+}\n+\n+static int\n+ngbe_set_vf_mc_promisc(struct rte_eth_dev *eth_dev,\n+\t\tuint32_t vf, uint32_t *msgbuf)\n+{\n+\tstruct ngbe_vf_info *vfinfo = *(NGBE_DEV_VFDATA(eth_dev));\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(eth_dev);\n+\tint xcast_mode = msgbuf[1];\t/* msgbuf contains the flag to enable */\n+\tu32 vmolr, fctrl, disable, enable;\n+\n+\tswitch (vfinfo[vf].api_version) {\n+\tcase ngbe_mbox_api_12:\n+\t\t/* promisc introduced in 1.3 version */\n+\t\tif (xcast_mode == NGBEVF_XCAST_MODE_PROMISC)\n+\t\t\treturn -EOPNOTSUPP;\n+\t\tbreak;\n+\t\t/* Fall threw */\n+\tcase ngbe_mbox_api_13:\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -1;\n+\t}\n+\n+\tif (vfinfo[vf].xcast_mode == xcast_mode)\n+\t\tgoto out;\n+\n+\tswitch (xcast_mode) {\n+\tcase NGBEVF_XCAST_MODE_NONE:\n+\t\tdisable = NGBE_POOLETHCTL_BCA | NGBE_POOLETHCTL_MCHA |\n+\t\t\t  NGBE_POOLETHCTL_MCP | NGBE_POOLETHCTL_UCP |\n+\t\t\t  NGBE_POOLETHCTL_VLP;\n+\t\tenable = 0;\n+\t\tbreak;\n+\tcase NGBEVF_XCAST_MODE_MULTI:\n+\t\tdisable = NGBE_POOLETHCTL_MCP | NGBE_POOLETHCTL_UCP |\n+\t\t\t  NGBE_POOLETHCTL_VLP;\n+\t\tenable = NGBE_POOLETHCTL_BCA | NGBE_POOLETHCTL_MCHA;\n+\t\tbreak;\n+\tcase NGBEVF_XCAST_MODE_ALLMULTI:\n+\t\tdisable = NGBE_POOLETHCTL_UCP | NGBE_POOLETHCTL_VLP;\n+\t\tenable = NGBE_POOLETHCTL_BCA | NGBE_POOLETHCTL_MCHA |\n+\t\t\t NGBE_POOLETHCTL_MCP;\n+\t\tbreak;\n+\tcase NGBEVF_XCAST_MODE_PROMISC:\n+\t\tfctrl = rd32(hw, NGBE_PSRCTL);\n+\t\tif (!(fctrl & NGBE_PSRCTL_UCP)) {\n+\t\t\t/* VF promisc requires PF in promisc */\n+\t\t\tPMD_DRV_LOG(ERR,\n+\t\t\t       \"Enabling VF promisc requires PF in promisc\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tdisable = 0;\n+\t\tenable = NGBE_POOLETHCTL_BCA | NGBE_POOLETHCTL_MCHA |\n+\t\t\t NGBE_POOLETHCTL_MCP | NGBE_POOLETHCTL_UCP |\n+\t\t\t NGBE_POOLETHCTL_VLP;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -1;\n+\t}\n+\n+\tvmolr = rd32(hw, NGBE_POOLETHCTL(vf));\n+\tvmolr &= ~disable;\n+\tvmolr |= enable;\n+\twr32(hw, NGBE_POOLETHCTL(vf), vmolr);\n+\tvfinfo[vf].xcast_mode = xcast_mode;\n+\n+out:\n+\tmsgbuf[1] = xcast_mode;\n+\n+\treturn 0;\n+}\n+\n+static int\n+ngbe_set_vf_macvlan_msg(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)\n+{\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(dev);\n+\tstruct ngbe_vf_info *vf_info = *(NGBE_DEV_VFDATA(dev));\n+\tuint8_t *new_mac = (uint8_t *)(&msgbuf[1]);\n+\tstruct rte_ether_addr *ea = (struct rte_ether_addr *)new_mac;\n+\tint index = (msgbuf[0] & NGBE_VT_MSGINFO_MASK) >>\n+\t\t    NGBE_VT_MSGINFO_SHIFT;\n+\n+\tif (index) {\n+\t\tif (!rte_is_valid_assigned_ether_addr(ea)) {\n+\t\t\tPMD_DRV_LOG(ERR, \"set invalid mac vf:%d\\n\", vf);\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tvf_info[vf].mac_count++;\n+\n+\t\thw->mac.set_rar(hw, vf_info[vf].mac_count,\n+\t\t\t\tnew_mac, vf, true);\n+\t} else {\n+\t\tif (vf_info[vf].mac_count) {\n+\t\t\thw->mac.clear_rar(hw, vf_info[vf].mac_count);\n+\t\t\tvf_info[vf].mac_count = 0;\n+\t\t}\n+\t}\n+\treturn 0;\n+}\n+\n+static int\n+ngbe_rcv_msg_from_vf(struct rte_eth_dev *eth_dev, uint16_t vf)\n+{\n+\tuint16_t mbx_size = NGBE_P2VMBX_SIZE;\n+\tuint16_t msg_size = NGBE_VF_MSG_SIZE_DEFAULT;\n+\tuint32_t msgbuf[NGBE_P2VMBX_SIZE];\n+\tint32_t retval;\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(eth_dev);\n+\tstruct ngbe_vf_info *vfinfo = *NGBE_DEV_VFDATA(eth_dev);\n+\tstruct rte_pmd_ngbe_mb_event_param ret_param;\n+\n+\tretval = ngbe_read_mbx(hw, msgbuf, mbx_size, vf);\n+\tif (retval) {\n+\t\tPMD_DRV_LOG(ERR, \"Error mbx recv msg from VF %d\", vf);\n+\t\treturn retval;\n+\t}\n+\n+\t/* do nothing with the message already been processed */\n+\tif (msgbuf[0] & (NGBE_VT_MSGTYPE_ACK | NGBE_VT_MSGTYPE_NACK))\n+\t\treturn retval;\n+\n+\t/* flush the ack before we write any messages back */\n+\tngbe_flush(hw);\n+\n+\t/**\n+\t * initialise structure to send to user application\n+\t * will return response from user in retval field\n+\t */\n+\tret_param.retval = RTE_PMD_NGBE_MB_EVENT_PROCEED;\n+\tret_param.vfid = vf;\n+\tret_param.msg_type = msgbuf[0] & 0xFFFF;\n+\tret_param.msg = (void *)msgbuf;\n+\n+\t/* perform VF reset */\n+\tif (msgbuf[0] == NGBE_VF_RESET) {\n+\t\tint ret = ngbe_vf_reset(eth_dev, vf, msgbuf);\n+\n+\t\tvfinfo[vf].clear_to_send = true;\n+\n+\t\t/* notify application about VF reset */\n+\t\trte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_VF_MBOX,\n+\t\t\t\t\t      &ret_param);\n+\t\treturn ret;\n+\t}\n+\n+\t/**\n+\t * ask user application if we allowed to perform those functions\n+\t * if we get ret_param.retval == RTE_PMD_COMPAT_MB_EVENT_PROCEED\n+\t * then business as usual,\n+\t * if 0, do nothing and send ACK to VF\n+\t * if ret_param.retval > 1, do nothing and send NAK to VF\n+\t */\n+\trte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_VF_MBOX,\n+\t\t\t\t      &ret_param);\n+\n+\tretval = ret_param.retval;\n+\n+\t/* check & process VF to PF mailbox message */\n+\tswitch ((msgbuf[0] & 0xFFFF)) {\n+\tcase NGBE_VF_SET_MAC_ADDR:\n+\t\tif (retval == RTE_PMD_NGBE_MB_EVENT_PROCEED)\n+\t\t\tretval = ngbe_vf_set_mac_addr(eth_dev, vf, msgbuf);\n+\t\tbreak;\n+\tcase NGBE_VF_SET_MULTICAST:\n+\t\tif (retval == RTE_PMD_NGBE_MB_EVENT_PROCEED)\n+\t\t\tretval = ngbe_vf_set_multicast(eth_dev, vf, msgbuf);\n+\t\tbreak;\n+\tcase NGBE_VF_SET_LPE:\n+\t\tif (retval == RTE_PMD_NGBE_MB_EVENT_PROCEED)\n+\t\t\tretval = ngbe_set_vf_lpe(eth_dev, vf, msgbuf);\n+\t\tbreak;\n+\tcase NGBE_VF_SET_VLAN:\n+\t\tif (retval == RTE_PMD_NGBE_MB_EVENT_PROCEED)\n+\t\t\tretval = ngbe_vf_set_vlan(eth_dev, vf, msgbuf);\n+\t\tbreak;\n+\tcase NGBE_VF_API_NEGOTIATE:\n+\t\tretval = ngbe_negotiate_vf_api(eth_dev, vf, msgbuf);\n+\t\tbreak;\n+\tcase NGBE_VF_GET_QUEUES:\n+\t\tretval = ngbe_get_vf_queues(eth_dev, vf, msgbuf);\n+\t\tmsg_size = NGBE_VF_GET_QUEUE_MSG_SIZE;\n+\t\tbreak;\n+\tcase NGBE_VF_UPDATE_XCAST_MODE:\n+\t\tif (retval == RTE_PMD_NGBE_MB_EVENT_PROCEED)\n+\t\t\tretval = ngbe_set_vf_mc_promisc(eth_dev, vf, msgbuf);\n+\t\tbreak;\n+\tcase NGBE_VF_SET_MACVLAN:\n+\t\tif (retval == RTE_PMD_NGBE_MB_EVENT_PROCEED)\n+\t\t\tretval = ngbe_set_vf_macvlan_msg(eth_dev, vf, msgbuf);\n+\t\tbreak;\n+\tdefault:\n+\t\tPMD_DRV_LOG(DEBUG, \"Unhandled Msg %8.8x\", (uint32_t)msgbuf[0]);\n+\t\tretval = NGBE_ERR_MBX;\n+\t\tbreak;\n+\t}\n+\n+\t/* response the VF according to the message process result */\n+\tif (retval)\n+\t\tmsgbuf[0] |= NGBE_VT_MSGTYPE_NACK;\n+\telse\n+\t\tmsgbuf[0] |= NGBE_VT_MSGTYPE_ACK;\n+\n+\tmsgbuf[0] |= NGBE_VT_MSGTYPE_CTS;\n+\n+\tngbe_write_mbx(hw, msgbuf, msg_size, vf);\n+\n+\treturn retval;\n+}\n+\n+static inline void\n+ngbe_rcv_ack_from_vf(struct rte_eth_dev *eth_dev, uint16_t vf)\n+{\n+\tuint32_t msg = NGBE_VT_MSGTYPE_NACK;\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(eth_dev);\n+\tstruct ngbe_vf_info *vfinfo = *NGBE_DEV_VFDATA(eth_dev);\n+\n+\tif (!vfinfo[vf].clear_to_send)\n+\t\tngbe_write_mbx(hw, &msg, 1, vf);\n+}\n+\n+void ngbe_pf_mbx_process(struct rte_eth_dev *eth_dev)\n+{\n+\tuint16_t vf;\n+\tstruct ngbe_hw *hw = ngbe_dev_hw(eth_dev);\n+\n+\tfor (vf = 0; vf < dev_num_vf(eth_dev); vf++) {\n+\t\t/* check & process vf function level reset */\n+\t\tif (!ngbe_check_for_rst(hw, vf))\n+\t\t\tngbe_vf_reset_event(eth_dev, vf);\n+\n+\t\t/* check & process vf mailbox messages */\n+\t\tif (!ngbe_check_for_msg(hw, vf))\n+\t\t\tngbe_rcv_msg_from_vf(eth_dev, vf);\n+\n+\t\t/* check & process acks from vf */\n+\t\tif (!ngbe_check_for_ack(hw, vf))\n+\t\t\tngbe_rcv_ack_from_vf(eth_dev, vf);\n+\t}\n+}\ndiff --git a/drivers/net/ngbe/rte_pmd_ngbe.h b/drivers/net/ngbe/rte_pmd_ngbe.h\nnew file mode 100644\nindex 0000000000..e895ecd7ef\n--- /dev/null\n+++ b/drivers/net/ngbe/rte_pmd_ngbe.h\n@@ -0,0 +1,39 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd.\n+ * Copyright(c) 2010-2017 Intel Corporation\n+ */\n+\n+/**\n+ * @file rte_pmd_ngbe.h\n+ * ngbe PMD specific functions.\n+ *\n+ **/\n+\n+#ifndef _PMD_NGBE_H_\n+#define _PMD_NGBE_H_\n+\n+#include <rte_compat.h>\n+#include <rte_ethdev.h>\n+#include <rte_ether.h>\n+\n+/**\n+ * Response sent back to ngbe driver from user app after callback\n+ */\n+enum rte_pmd_ngbe_mb_event_rsp {\n+\tRTE_PMD_NGBE_MB_EVENT_NOOP_ACK,  /**< skip mbox request and ACK */\n+\tRTE_PMD_NGBE_MB_EVENT_NOOP_NACK, /**< skip mbox request and NACK */\n+\tRTE_PMD_NGBE_MB_EVENT_PROCEED,  /**< proceed with mbox request  */\n+\tRTE_PMD_NGBE_MB_EVENT_MAX       /**< max value of this enum */\n+};\n+\n+/**\n+ * Data sent to the user application when the callback is executed.\n+ */\n+struct rte_pmd_ngbe_mb_event_param {\n+\tuint16_t vfid;     /**< Virtual Function number */\n+\tuint16_t msg_type; /**< VF to PF message type, defined in ngbe_mbx.h */\n+\tuint16_t retval;   /**< return value */\n+\tvoid *msg;         /**< pointer to message */\n+};\n+\n+#endif /* _PMD_NGBE_H_ */\n",
    "prefixes": [
        "19/32"
    ]
}