get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 91258,
    "url": "https://patches.dpdk.org/api/patches/91258/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1618321639-57642-7-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-7-git-send-email-humin29@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1618321639-57642-7-git-send-email-humin29@huawei.com",
    "date": "2021-04-13T13:47:16",
    "name": "[6/9] net/hns3: report the speed capability for PF",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "9a5fc8452442368784674b5650a2b541b38379a3",
    "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-7-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/91258/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/91258/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 A015CA0524;\n\tTue, 13 Apr 2021 15:47:58 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 48777160FF1;\n\tTue, 13 Apr 2021 15:47:17 +0200 (CEST)",
            "from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32])\n by mails.dpdk.org (Postfix) with ESMTP id EA6D7160FC4\n for <dev@dpdk.org>; Tue, 13 Apr 2021 15:47:07 +0200 (CEST)",
            "from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59])\n by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4FKRgY4Z2fzlXpr\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:01 +0800"
        ],
        "From": "\"Min Hu (Connor)\" <humin29@huawei.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<ferruh.yigit@intel.com>",
        "Date": "Tue, 13 Apr 2021 21:47:16 +0800",
        "Message-ID": "<1618321639-57642-7-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 6/9] net/hns3: report the speed capability for PF",
        "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 speed capability of the device can be reported to the upper-layer app\nin rte_eth_dev_info_get API. In this API, the speed capability is derived\nfrom the 'supported_speed', which is the speed capability actually\nsupported by the NIC. The value of the 'supported_speed' is obtained\nonce in the probe stage and may be updated in the scheduled task to deal\nwith the change of the transmission interface.\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 | 136 +++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 136 insertions(+)",
    "diff": "diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c\nindex e8ae288..7893379 100644\n--- a/drivers/net/hns3/hns3_ethdev.c\n+++ b/drivers/net/hns3/hns3_ethdev.c\n@@ -2617,6 +2617,67 @@ hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)\n \treturn 0;\n }\n \n+static uint32_t\n+hns3_get_copper_port_speed_capa(uint32_t supported_speed)\n+{\n+\tuint32_t speed_capa = 0;\n+\n+\tif (supported_speed & HNS3_PHY_LINK_SPEED_10M_HD_BIT)\n+\t\tspeed_capa |= ETH_LINK_SPEED_10M_HD;\n+\tif (supported_speed & HNS3_PHY_LINK_SPEED_10M_BIT)\n+\t\tspeed_capa |= ETH_LINK_SPEED_10M;\n+\tif (supported_speed & HNS3_PHY_LINK_SPEED_100M_HD_BIT)\n+\t\tspeed_capa |= ETH_LINK_SPEED_100M_HD;\n+\tif (supported_speed & HNS3_PHY_LINK_SPEED_100M_BIT)\n+\t\tspeed_capa |= ETH_LINK_SPEED_100M;\n+\tif (supported_speed & HNS3_PHY_LINK_SPEED_1000M_BIT)\n+\t\tspeed_capa |= ETH_LINK_SPEED_1G;\n+\n+\treturn speed_capa;\n+}\n+\n+static uint32_t\n+hns3_get_firber_port_speed_capa(uint32_t supported_speed)\n+{\n+\tuint32_t speed_capa = 0;\n+\n+\tif (supported_speed & HNS3_FIBER_LINK_SPEED_1G_BIT)\n+\t\tspeed_capa |= ETH_LINK_SPEED_1G;\n+\tif (supported_speed & HNS3_FIBER_LINK_SPEED_10G_BIT)\n+\t\tspeed_capa |= ETH_LINK_SPEED_10G;\n+\tif (supported_speed & HNS3_FIBER_LINK_SPEED_25G_BIT)\n+\t\tspeed_capa |= ETH_LINK_SPEED_25G;\n+\tif (supported_speed & HNS3_FIBER_LINK_SPEED_40G_BIT)\n+\t\tspeed_capa |= ETH_LINK_SPEED_40G;\n+\tif (supported_speed & HNS3_FIBER_LINK_SPEED_50G_BIT)\n+\t\tspeed_capa |= ETH_LINK_SPEED_50G;\n+\tif (supported_speed & HNS3_FIBER_LINK_SPEED_100G_BIT)\n+\t\tspeed_capa |= ETH_LINK_SPEED_100G;\n+\tif (supported_speed & HNS3_FIBER_LINK_SPEED_200G_BIT)\n+\t\tspeed_capa |= ETH_LINK_SPEED_200G;\n+\n+\treturn speed_capa;\n+}\n+\n+static uint32_t\n+hns3_get_speed_capa(struct hns3_hw *hw)\n+{\n+\tstruct hns3_mac *mac = &hw->mac;\n+\tuint32_t speed_capa;\n+\n+\tif (mac->media_type == HNS3_MEDIA_TYPE_COPPER)\n+\t\tspeed_capa =\n+\t\t\thns3_get_copper_port_speed_capa(mac->supported_speed);\n+\telse\n+\t\tspeed_capa =\n+\t\t\thns3_get_firber_port_speed_capa(mac->supported_speed);\n+\n+\tif (mac->support_autoneg == 0)\n+\t\tspeed_capa |= ETH_LINK_SPEED_FIXED;\n+\n+\treturn speed_capa;\n+}\n+\n int\n hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)\n {\n@@ -2688,6 +2749,7 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)\n \t\t.nb_mtu_seg_max = hw->max_non_tso_bd_num,\n \t};\n \n+\tinfo->speed_capa = hns3_get_speed_capa(hw);\n \tinfo->default_rxconf = (struct rte_eth_rxconf) {\n \t\t.rx_free_thresh = HNS3_DEFAULT_RX_FREE_THRESH,\n \t\t/*\n@@ -4957,6 +5019,71 @@ hns3_config_all_msix_error(struct hns3_hw *hw, bool enable)\n \thns3_write_dev(hw, HNS3_VECTOR0_OTER_EN_REG, val);\n }\n \n+static uint32_t\n+hns3_set_firber_default_support_speed(struct hns3_hw *hw)\n+{\n+\tstruct hns3_mac *mac = &hw->mac;\n+\n+\tswitch (mac->link_speed) {\n+\tcase ETH_SPEED_NUM_1G:\n+\t\treturn HNS3_FIBER_LINK_SPEED_1G_BIT;\n+\tcase ETH_SPEED_NUM_10G:\n+\t\treturn HNS3_FIBER_LINK_SPEED_10G_BIT;\n+\tcase ETH_SPEED_NUM_25G:\n+\t\treturn HNS3_FIBER_LINK_SPEED_25G_BIT;\n+\tcase ETH_SPEED_NUM_40G:\n+\t\treturn HNS3_FIBER_LINK_SPEED_40G_BIT;\n+\tcase ETH_SPEED_NUM_50G:\n+\t\treturn HNS3_FIBER_LINK_SPEED_50G_BIT;\n+\tcase ETH_SPEED_NUM_100G:\n+\t\treturn HNS3_FIBER_LINK_SPEED_100G_BIT;\n+\tcase ETH_SPEED_NUM_200G:\n+\t\treturn HNS3_FIBER_LINK_SPEED_200G_BIT;\n+\tdefault:\n+\t\thns3_warn(hw, \"invalid speed %u Mbps.\", mac->link_speed);\n+\t\treturn 0;\n+\t}\n+}\n+\n+/*\n+ * Validity of supported_speed for firber and copper media type can be\n+ * guaranteed by the following policy:\n+ * Copper:\n+ *       Although the initialization of the phy in the firmware may not be\n+ *       completed, the firmware can guarantees that the supported_speed is\n+ *       an valid value.\n+ * Firber:\n+ *       If the version of firmware supports the acitive query way of the\n+ *       HNS3_OPC_GET_SFP_INFO opcode, the supported_speed can be obtained\n+ *       through it. If unsupported, use the SFP's speed as the value of the\n+ *       supported_speed.\n+ */\n+static int\n+hns3_get_port_supported_speed(struct rte_eth_dev *eth_dev)\n+{\n+\tstruct hns3_adapter *hns = eth_dev->data->dev_private;\n+\tstruct hns3_hw *hw = &hns->hw;\n+\tstruct hns3_mac *mac = &hw->mac;\n+\tint ret;\n+\n+\tret = hns3_update_link_info(eth_dev);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tif (mac->media_type == HNS3_MEDIA_TYPE_FIBER) {\n+\t\t/*\n+\t\t * Some firmware does not support the report of supported_speed,\n+\t\t * and only report the effective speed of SFP. In this case, it\n+\t\t * is necessary to use the SFP's speed as the supported_speed.\n+\t\t */\n+\t\tif (mac->supported_speed == 0)\n+\t\t\tmac->supported_speed =\n+\t\t\t\thns3_set_firber_default_support_speed(hw);\n+\t}\n+\n+\treturn 0;\n+}\n+\n static int\n hns3_init_pf(struct rte_eth_dev *eth_dev)\n {\n@@ -5057,10 +5184,19 @@ hns3_init_pf(struct rte_eth_dev *eth_dev)\n \t\tgoto err_enable_intr;\n \t}\n \n+\tret = hns3_get_port_supported_speed(eth_dev);\n+\tif (ret) {\n+\t\tPMD_INIT_LOG(ERR, \"failed to get speed capabilities supported \"\n+\t\t\t     \"by device, ret = %d.\", ret);\n+\t\tgoto err_supported_speed;\n+\t}\n+\n \thns3_tm_conf_init(eth_dev);\n \n \treturn 0;\n \n+err_supported_speed:\n+\t(void)hns3_enable_hw_error_intr(hns, false);\n err_enable_intr:\n \thns3_fdir_filter_uninit(hns);\n err_fdir:\n",
    "prefixes": [
        "6/9"
    ]
}