get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 91253,
    "url": "https://patches.dpdk.org/api/patches/91253/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1618321639-57642-9-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-9-git-send-email-humin29@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1618321639-57642-9-git-send-email-humin29@huawei.com",
    "date": "2021-04-13T13:47:18",
    "name": "[8/9] net/hns3: support flow control autoneg for copper port",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "1c19d8fad46cd48e1ea4768df05525b35fd9be16",
    "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-9-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/91253/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/91253/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 413B9A0524;\n\tTue, 13 Apr 2021 15:47:21 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 85A4F160FC6;\n\tTue, 13 Apr 2021 15:47:10 +0200 (CEST)",
            "from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32])\n by mails.dpdk.org (Postfix) with ESMTP id D22FC160FC4\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 4FKRgY2vqmzlXpR\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:02 +0800"
        ],
        "From": "\"Min Hu (Connor)\" <humin29@huawei.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<ferruh.yigit@intel.com>",
        "Date": "Tue, 13 Apr 2021 21:47:18 +0800",
        "Message-ID": "<1618321639-57642-9-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 8/9] net/hns3: support flow control autoneg for\n copper port",
        "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\nIf the flow control auto-negotiation is not supported and the flow\ncontrol modes on the local and link partner is asymmetric, the flow\ncontrol on the NIC does not take effect. The support of the\nauto-negotiation capability requires the cooperation of the firmware\nand driver.\n\nThis patch supports the flow control auto-negotiation only for copper\nport. For optical ports, the forced flow control mode is still used.\n\nSigned-off-by: Huisong Li <lihuisong@huawei.com>\nSigned-off-by: Min Hu (Connor) <humin29@huawei.com>\n---\n drivers/net/hns3/hns3_ethdev.c | 162 ++++++++++++++++++++++++++++++++++++++---\n 1 file changed, 152 insertions(+), 10 deletions(-)",
    "diff": "diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c\nindex e251b97..6262bf0 100644\n--- a/drivers/net/hns3/hns3_ethdev.c\n+++ b/drivers/net/hns3/hns3_ethdev.c\n@@ -5088,6 +5088,24 @@ hns3_get_port_supported_speed(struct rte_eth_dev *eth_dev)\n \treturn 0;\n }\n \n+static void\n+hns3_get_fc_autoneg_capability(struct hns3_adapter *hns)\n+{\n+\tstruct hns3_mac *mac = &hns->hw.mac;\n+\n+\tif (mac->media_type == HNS3_MEDIA_TYPE_COPPER) {\n+\t\thns->pf.support_fc_autoneg = true;\n+\t\treturn;\n+\t}\n+\n+\t/*\n+\t * Flow control auto-negotiation requires the cooperation of the driver\n+\t * and firmware. Currently, the optical port does not support flow\n+\t * control auto-negotiation.\n+\t */\n+\thns->pf.support_fc_autoneg = false;\n+}\n+\n static int\n hns3_init_pf(struct rte_eth_dev *eth_dev)\n {\n@@ -5195,6 +5213,8 @@ hns3_init_pf(struct rte_eth_dev *eth_dev)\n \t\tgoto err_supported_speed;\n \t}\n \n+\thns3_get_fc_autoneg_capability(hns);\n+\n \thns3_tm_conf_init(eth_dev);\n \n \treturn 0;\n@@ -5761,19 +5781,102 @@ hns3_dev_close(struct rte_eth_dev *eth_dev)\n \treturn ret;\n }\n \n-static int\n-hns3_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)\n+static void\n+hns3_get_autoneg_rxtx_pause_copper(struct hns3_hw *hw, bool *rx_pause,\n+\t\t\t\t   bool *tx_pause)\n+{\n+\tstruct hns3_mac *mac = &hw->mac;\n+\tuint32_t advertising = mac->advertising;\n+\tuint32_t lp_advertising = mac->lp_advertising;\n+\t*rx_pause = false;\n+\t*tx_pause = false;\n+\n+\tif (advertising & lp_advertising & HNS3_PHY_LINK_MODE_PAUSE_BIT) {\n+\t\t*rx_pause = true;\n+\t\t*tx_pause = true;\n+\t} else if (advertising & lp_advertising &\n+\t\t   HNS3_PHY_LINK_MODE_ASYM_PAUSE_BIT) {\n+\t\tif (advertising & HNS3_PHY_LINK_MODE_PAUSE_BIT)\n+\t\t\t*rx_pause = true;\n+\t\telse if (lp_advertising & HNS3_PHY_LINK_MODE_PAUSE_BIT)\n+\t\t\t*tx_pause = true;\n+\t}\n+}\n+\n+static enum hns3_fc_mode\n+hns3_get_autoneg_fc_mode(struct hns3_hw *hw)\n+{\n+\tenum hns3_fc_mode current_mode;\n+\tbool rx_pause = false;\n+\tbool tx_pause = false;\n+\n+\tswitch (hw->mac.media_type) {\n+\tcase HNS3_MEDIA_TYPE_COPPER:\n+\t\thns3_get_autoneg_rxtx_pause_copper(hw, &rx_pause, &tx_pause);\n+\t\tbreak;\n+\n+\t/*\n+\t * Flow control auto-negotiation is not supported for fiber and\n+\t * backpalne media type.\n+\t */\n+\tcase HNS3_MEDIA_TYPE_FIBER:\n+\tcase HNS3_MEDIA_TYPE_BACKPLANE:\n+\t\thns3_err(hw, \"autoneg FC mode can't be obtained, but flow control auto-negotiation is enabled.\");\n+\t\tcurrent_mode = hw->requested_fc_mode;\n+\t\tgoto out;\n+\tdefault:\n+\t\thns3_err(hw, \"autoneg FC mode can't be obtained for unknown media type(%u).\",\n+\t\t\t hw->mac.media_type);\n+\t\tcurrent_mode = HNS3_FC_NONE;\n+\t\tgoto out;\n+\t}\n+\n+\tif (rx_pause && tx_pause)\n+\t\tcurrent_mode = HNS3_FC_FULL;\n+\telse if (rx_pause)\n+\t\tcurrent_mode = HNS3_FC_RX_PAUSE;\n+\telse if (tx_pause)\n+\t\tcurrent_mode = HNS3_FC_TX_PAUSE;\n+\telse\n+\t\tcurrent_mode = HNS3_FC_NONE;\n+\n+out:\n+\treturn current_mode;\n+}\n+\n+static enum hns3_fc_mode\n+hns3_get_current_fc_mode(struct rte_eth_dev *dev)\n {\n \tstruct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n \tstruct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n+\tstruct hns3_mac *mac = &hw->mac;\n \n-\tfc_conf->pause_time = pf->pause_time;\n+\t/*\n+\t * When the flow control mode is obtained, the device may not complete\n+\t * auto-negotiation. It is necessary to wait for link establishment.\n+\t */\n+\t(void)hns3_dev_link_update(dev, 1);\n \n \t/*\n-\t * If fc auto-negotiation is not supported, the configured fc mode\n-\t * from user is the current fc mode.\n+\t * If the link auto-negotiation of the nic is disabled, or the flow\n+\t * control auto-negotiation is not supported, the forced flow control\n+\t * mode is used.\n \t */\n-\tswitch (hw->requested_fc_mode) {\n+\tif (mac->link_autoneg == 0 || !pf->support_fc_autoneg)\n+\t\treturn hw->requested_fc_mode;\n+\n+\treturn hns3_get_autoneg_fc_mode(hw);\n+}\n+\n+static int\n+hns3_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)\n+{\n+\tstruct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tstruct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n+\tenum hns3_fc_mode current_mode;\n+\n+\tcurrent_mode = hns3_get_current_fc_mode(dev);\n+\tswitch (current_mode) {\n \tcase HNS3_FC_FULL:\n \t\tfc_conf->mode = RTE_FC_FULL;\n \t\tbreak;\n@@ -5789,6 +5892,9 @@ hns3_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)\n \t\tbreak;\n \t}\n \n+\tfc_conf->pause_time = pf->pause_time;\n+\tfc_conf->autoneg = pf->support_fc_autoneg ? hw->mac.link_autoneg : 0;\n+\n \treturn 0;\n }\n \n@@ -5817,6 +5923,41 @@ hns3_get_fc_mode(struct hns3_hw *hw, enum rte_eth_fc_mode mode)\n }\n \n static int\n+hns3_check_fc_autoneg_valid(struct hns3_hw *hw, uint8_t autoneg)\n+{\n+\tstruct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw);\n+\n+\tif (!pf->support_fc_autoneg) {\n+\t\tif (autoneg != 0) {\n+\t\t\thns3_err(hw, \"unsupported fc auto-negotiation setting.\");\n+\t\t\treturn -EOPNOTSUPP;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Flow control auto-negotiation of the NIC is not supported,\n+\t\t * but other auto-negotiation features may be supported.\n+\t\t */\n+\t\tif (autoneg != hw->mac.link_autoneg) {\n+\t\t\thns3_err(hw, \"please use 'link_speeds' in struct rte_eth_conf to disable autoneg!\");\n+\t\t\treturn -EOPNOTSUPP;\n+\t\t}\n+\n+\t\treturn 0;\n+\t}\n+\n+\t/*\n+\t * If flow control auto-negotiation of the NIC is supported, all\n+\t * auto-negotiation features are supported.\n+\t */\n+\tif (autoneg != hw->mac.link_autoneg) {\n+\t\thns3_err(hw, \"please use 'link_speeds' in struct rte_eth_conf to change autoneg!\");\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n hns3_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)\n {\n \tstruct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n@@ -5831,10 +5972,11 @@ hns3_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)\n \t\t\t fc_conf->send_xon, fc_conf->mac_ctrl_frame_fwd);\n \t\treturn -EINVAL;\n \t}\n-\tif (fc_conf->autoneg) {\n-\t\thns3_err(hw, \"Unsupported fc auto-negotiation setting.\");\n-\t\treturn -EINVAL;\n-\t}\n+\n+\tret = hns3_check_fc_autoneg_valid(hw, fc_conf->autoneg);\n+\tif (ret)\n+\t\treturn ret;\n+\n \tif (!fc_conf->pause_time) {\n \t\thns3_err(hw, \"Invalid pause time %u setting.\",\n \t\t\t fc_conf->pause_time);\n",
    "prefixes": [
        "8/9"
    ]
}