get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 91255,
    "url": "https://patches.dpdk.org/api/patches/91255/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1618321639-57642-5-git-send-email-humin29@huawei.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1618321639-57642-5-git-send-email-humin29@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1618321639-57642-5-git-send-email-humin29@huawei.com",
    "date": "2021-04-13T13:47:14",
    "name": "[4/9] net/hns3: fix firmware compatibility configuration",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "2fb61252b6b40ce6cd3ac7232b262f6550fcf1f6",
    "submitter": {
        "id": 1944,
        "url": "https://patches.dpdk.org/api/people/1944/?format=api",
        "name": "humin (Q)",
        "email": "humin29@huawei.com"
    },
    "delegate": {
        "id": 319,
        "url": "https://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1618321639-57642-5-git-send-email-humin29@huawei.com/mbox/",
    "series": [
        {
            "id": 16336,
            "url": "https://patches.dpdk.org/api/series/16336/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=16336",
            "date": "2021-04-13T13:47:11",
            "name": "support speed capability and autoneg report",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/16336/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/91255/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/91255/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 45BF9A0524;\n\tTue, 13 Apr 2021 15:47:38 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 18688160FDC;\n\tTue, 13 Apr 2021 15:47:13 +0200 (CEST)",
            "from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32])\n by mails.dpdk.org (Postfix) with ESMTP id D8D28160FC6\n for <dev@dpdk.org>; Tue, 13 Apr 2021 15:47:06 +0200 (CEST)",
            "from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59])\n by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4FKRgY4LjLzlXpp\n for <dev@dpdk.org>; Tue, 13 Apr 2021 21:45:13 +0800 (CST)",
            "from localhost.localdomain (10.69.192.56) by\n DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id\n 14.3.498.0; Tue, 13 Apr 2021 21:47:00 +0800"
        ],
        "From": "\"Min Hu (Connor)\" <humin29@huawei.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<ferruh.yigit@intel.com>",
        "Date": "Tue, 13 Apr 2021 21:47:14 +0800",
        "Message-ID": "<1618321639-57642-5-git-send-email-humin29@huawei.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1618321639-57642-1-git-send-email-humin29@huawei.com>",
        "References": "<1618321639-57642-1-git-send-email-humin29@huawei.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.69.192.56]",
        "X-CFilter-Loop": "Reflected",
        "Subject": "[dpdk-dev] [PATCH 4/9] net/hns3: fix firmware compatibility\n configuration",
        "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": "From: Huisong Li <lihuisong@huawei.com>\n\nThe firmware compatibility configuration in PF driver is used to\nmaintain the compatibility of some features of the driver and\nfirmware, and requires firmware to enable these features. Currently,\nthe configuration is in hns3_init_hardware(), which is a little back.\nBecause firmware may clear some configurations (such as, MAC related)\nafter receiving the command. And firmware can not be aware of some\ndefault initializations (such as, flow control) before executing the\ncommand to set the copper PHY when the PHY is controlled by firmware.\nTherefore, it is recommended that no other hardware resources are\nconfigured before the compatibility configuration. And it should be\nmoved to hns3_cmd_init(), which is responsible for the firmware\ncommand initialization of driver.\n\nIn addition, the driver needs to perform corresponding processing\nif the command fails to be sent.\n1) If firmware fails to take over the copper PHY, the copper port\nfails to initialize.\n2) If fails to enable the report of link events, the device does\nnot support the LSC capability.\n\nFixes: 7035ee35e26b (\"net/hns3: refactor PF LSC event report\")\nFixes: bac6a0644121 (\"net/hns3: fix link status change from firmware\")\nCc: stable@dpdk.org\n\nSigned-off-by: Huisong Li <lihuisong@huawei.com>\nSigned-off-by: Min Hu (Connor) <humin29@huawei.com>\n---\n drivers/net/hns3/hns3_cmd.c    | 116 +++++++++++++++++++++++++++++++++++++++++\n drivers/net/hns3/hns3_ethdev.c |  56 --------------------\n 2 files changed, 116 insertions(+), 56 deletions(-)",
    "diff": "diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c\nindex 1d8ef7a..e6900ec 100644\n--- a/drivers/net/hns3/hns3_cmd.c\n+++ b/drivers/net/hns3/hns3_cmd.c\n@@ -515,9 +515,99 @@ hns3_cmd_init_queue(struct hns3_hw *hw)\n \treturn ret;\n }\n \n+static void\n+hns3_update_dev_lsc_cap(struct hns3_hw *hw, int fw_compact_cmd_result)\n+{\n+\tstruct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id];\n+\n+\tif (hw->adapter_state != HNS3_NIC_UNINITIALIZED)\n+\t\treturn;\n+\n+\tif (fw_compact_cmd_result != 0) {\n+\t\t/*\n+\t\t * If fw_compact_cmd_result is not zero, it means firmware don't\n+\t\t * support link status change interrupt.\n+\t\t * Framework already set RTE_ETH_DEV_INTR_LSC bit because driver\n+\t\t * declared RTE_PCI_DRV_INTR_LSC in drv_flags. It need to clear\n+\t\t * the RTE_ETH_DEV_INTR_LSC capability when detect firmware\n+\t\t * don't support link status change interrupt.\n+\t\t */\n+\t\tdev->data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC;\n+\t}\n+}\n+\n+static int\n+hns3_apply_fw_compat_cmd_result(struct hns3_hw *hw, int result)\n+{\n+\tif (result != 0 && hns3_dev_copper_supported(hw)) {\n+\t\thns3_err(hw, \"firmware fails to initialize the PHY, ret = %d.\",\n+\t\t\t result);\n+\t\treturn result;\n+\t}\n+\n+\thns3_update_dev_lsc_cap(hw, result);\n+\n+\treturn 0;\n+}\n+\n+static int\n+hns3_firmware_compat_config(struct hns3_hw *hw, bool is_init)\n+{\n+\tstruct hns3_firmware_compat_cmd *req;\n+\tstruct hns3_cmd_desc desc;\n+\tuint32_t compat = 0;\n+\n+#if defined(RTE_HNS3_ONLY_1630_FPGA)\n+\t/* If resv reg enabled phy driver of imp is not configured, driver\n+\t * will use temporary phy driver.\n+\t */\n+\tstruct rte_pci_device *pci_dev;\n+\tstruct rte_eth_dev *eth_dev;\n+\tuint8_t revision;\n+\tint ret;\n+\n+\teth_dev = &rte_eth_devices[hw->data->port_id];\n+\tpci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);\n+\t/* Get PCI revision id */\n+\tret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN,\n+\t\t\t\t  HNS3_PCI_REVISION_ID);\n+\tif (ret != HNS3_PCI_REVISION_ID_LEN) {\n+\t\tPMD_INIT_LOG(ERR, \"failed to read pci revision id, ret = %d\",\n+\t\t\t     ret);\n+\t\treturn -EIO;\n+\t}\n+\tif (revision == PCI_REVISION_ID_HIP09_A) {\n+\t\tstruct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw);\n+\t\tif (hns3_dev_copper_supported(hw) == 0 || pf->is_tmp_phy) {\n+\t\t\tPMD_INIT_LOG(ERR, \"***use temp phy driver in dpdk***\");\n+\t\t\tpf->is_tmp_phy = true;\n+\t\t\thns3_set_bit(hw->capability,\n+\t\t\t\t     HNS3_DEV_SUPPORT_COPPER_B, 1);\n+\t\t\treturn 0;\n+\t\t}\n+\n+\t\tPMD_INIT_LOG(ERR, \"***use phy driver in imp***\");\n+\t}\n+#endif\n+\n+\thns3_cmd_setup_basic_desc(&desc, HNS3_OPC_FIRMWARE_COMPAT_CFG, false);\n+\treq = (struct hns3_firmware_compat_cmd *)desc.data;\n+\n+\tif (is_init) {\n+\t\thns3_set_bit(compat, HNS3_LINK_EVENT_REPORT_EN_B, 1);\n+\t\thns3_set_bit(compat, HNS3_NCSI_ERROR_REPORT_EN_B, 0);\n+\t\tif (hns3_dev_copper_supported(hw))\n+\t\t\thns3_set_bit(compat, HNS3_FIRMWARE_PHY_DRIVER_EN_B, 1);\n+\t}\n+\treq->compat = rte_cpu_to_le_32(compat);\n+\n+\treturn hns3_cmd_send(hw, &desc, 1);\n+}\n+\n int\n hns3_cmd_init(struct hns3_hw *hw)\n {\n+\tstruct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);\n \tuint32_t version;\n \tint ret;\n \n@@ -564,6 +654,27 @@ hns3_cmd_init(struct hns3_hw *hw)\n \t\t     hns3_get_field(version, HNS3_FW_VERSION_BYTE0_M,\n \t\t\t\t    HNS3_FW_VERSION_BYTE0_S));\n \n+\tif (hns->is_vf)\n+\t\treturn 0;\n+\n+\t/*\n+\t * Requiring firmware to enable some features, firber port can still\n+\t * work without it, but copper port can't work because the firmware\n+\t * fails to take over the PHY.\n+\t */\n+\tret = hns3_firmware_compat_config(hw, true);\n+\tif (ret)\n+\t\tPMD_INIT_LOG(WARNING, \"firmware compatible features not \"\n+\t\t\t     \"supported, ret = %d.\", ret);\n+\n+\t/*\n+\t * Perform some corresponding operations based on the firmware\n+\t * compatibility configuration result.\n+\t */\n+\tret = hns3_apply_fw_compat_cmd_result(hw, ret);\n+\tif (ret)\n+\t\tgoto err_cmd_init;\n+\n \treturn 0;\n \n err_cmd_init:\n@@ -591,6 +702,11 @@ hns3_cmd_destroy_queue(struct hns3_hw *hw)\n void\n hns3_cmd_uninit(struct hns3_hw *hw)\n {\n+\tstruct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);\n+\n+\tif (!hns->is_vf)\n+\t\t(void)hns3_firmware_compat_config(hw, false);\n+\n \t__atomic_store_n(&hw->reset.disable_cmd, 1, __ATOMIC_RELAXED);\n \n \t/*\ndiff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c\nindex 62a23b8..d22d31d 100644\n--- a/drivers/net/hns3/hns3_ethdev.c\n+++ b/drivers/net/hns3/hns3_ethdev.c\n@@ -4118,28 +4118,6 @@ hns3_buffer_alloc(struct hns3_hw *hw)\n }\n \n static int\n-hns3_firmware_compat_config(struct hns3_hw *hw, bool is_init)\n-{\n-\tstruct hns3_firmware_compat_cmd *req;\n-\tstruct hns3_cmd_desc desc;\n-\tuint32_t compat = 0;\n-\n-\thns3_cmd_setup_basic_desc(&desc, HNS3_OPC_FIRMWARE_COMPAT_CFG, false);\n-\treq = (struct hns3_firmware_compat_cmd *)desc.data;\n-\n-\tif (is_init) {\n-\t\thns3_set_bit(compat, HNS3_LINK_EVENT_REPORT_EN_B, 1);\n-\t\thns3_set_bit(compat, HNS3_NCSI_ERROR_REPORT_EN_B, 0);\n-\t\tif (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER)\n-\t\t\thns3_set_bit(compat, HNS3_FIRMWARE_PHY_DRIVER_EN_B, 1);\n-\t}\n-\n-\treq->compat = rte_cpu_to_le_32(compat);\n-\n-\treturn hns3_cmd_send(hw, &desc, 1);\n-}\n-\n-static int\n hns3_mac_init(struct hns3_hw *hw)\n {\n \tstruct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);\n@@ -4815,28 +4793,6 @@ hns3_service_handler(void *param)\n \trte_eal_alarm_set(HNS3_SERVICE_INTERVAL, hns3_service_handler, eth_dev);\n }\n \n-static void\n-hns3_update_dev_lsc_cap(struct hns3_hw *hw,\n-\t\t\tint fw_compact_cmd_result)\n-{\n-\tstruct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id];\n-\n-\tif (hw->adapter_state != HNS3_NIC_UNINITIALIZED)\n-\t\treturn;\n-\n-\tif (fw_compact_cmd_result != 0) {\n-\t\t/*\n-\t\t * If fw_compact_cmd_result is not zero, it means firmware don't\n-\t\t * support link status change interrupt.\n-\t\t * Framework already set RTE_ETH_DEV_INTR_LSC bit because driver\n-\t\t * declared RTE_PCI_DRV_INTR_LSC in drv_flags. It need to clear\n-\t\t * the RTE_ETH_DEV_INTR_LSC capability when detect firmware\n-\t\t * don't support link status change interrupt.\n-\t\t */\n-\t\tdev->data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC;\n-\t}\n-}\n-\n static int\n hns3_init_hardware(struct hns3_adapter *hns)\n {\n@@ -4916,16 +4872,6 @@ hns3_init_hardware(struct hns3_adapter *hns)\n \t\tgoto err_mac_init;\n \t}\n \n-\t/*\n-\t * Requiring firmware to enable some features, driver can\n-\t * still work without it.\n-\t */\n-\tret = hns3_firmware_compat_config(hw, true);\n-\tif (ret)\n-\t\tPMD_INIT_LOG(WARNING, \"firmware compatible features not \"\n-\t\t\t     \"supported, ret = %d.\", ret);\n-\thns3_update_dev_lsc_cap(hw, ret);\n-\n \treturn 0;\n \n err_mac_init:\n@@ -5073,7 +5019,6 @@ hns3_init_pf(struct rte_eth_dev *eth_dev)\n err_enable_intr:\n \thns3_fdir_filter_uninit(hns);\n err_fdir:\n-\t(void)hns3_firmware_compat_config(hw, false);\n \thns3_uninit_umv_space(hw);\n err_init_hw:\n \thns3_tqp_stats_uninit(hw);\n@@ -5108,7 +5053,6 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev)\n \t(void)hns3_config_gro(hw, false);\n \thns3_promisc_uninit(hw);\n \thns3_fdir_filter_uninit(hns);\n-\t(void)hns3_firmware_compat_config(hw, false);\n \thns3_uninit_umv_space(hw);\n \thns3_tqp_stats_uninit(hw);\n \thns3_config_mac_tnl_int(hw, false);\n",
    "prefixes": [
        "4/9"
    ]
}