get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 88117,
    "url": "http://patches.dpdk.org/api/patches/88117/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1614130139-42926-8-git-send-email-oulijun@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": "<1614130139-42926-8-git-send-email-oulijun@huawei.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1614130139-42926-8-git-send-email-oulijun@huawei.com",
    "date": "2021-02-24T01:28:53",
    "name": "[07/13] net/hns3: support PF on electrical net device",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "1c3e86fe079be3b15aa06bd1ddafa36b6e6a4f96",
    "submitter": {
        "id": 1675,
        "url": "http://patches.dpdk.org/api/people/1675/?format=api",
        "name": "Lijun Ou",
        "email": "oulijun@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/1614130139-42926-8-git-send-email-oulijun@huawei.com/mbox/",
    "series": [
        {
            "id": 15352,
            "url": "http://patches.dpdk.org/api/series/15352/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=15352",
            "date": "2021-02-24T01:28:57",
            "name": "Features and bugfixes for hns3",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/15352/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/88117/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/88117/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 548D4A034F;\n\tWed, 24 Feb 2021 02:29:08 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id C1E9616073F;\n\tWed, 24 Feb 2021 02:28:30 +0100 (CET)",
            "from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190])\n by mails.dpdk.org (Postfix) with ESMTP id 0AFB44068C\n for <dev@dpdk.org>; Wed, 24 Feb 2021 02:28:23 +0100 (CET)",
            "from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58])\n by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DldYc2Hk6z16C0K;\n Wed, 24 Feb 2021 09:26:44 +0800 (CST)",
            "from localhost.localdomain (10.69.192.56) by\n DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id\n 14.3.498.0; Wed, 24 Feb 2021 09:28:16 +0800"
        ],
        "From": "Lijun Ou <oulijun@huawei.com>",
        "To": "<ferruh.yigit@intel.com>",
        "CC": "<dev@dpdk.org>, <linuxarm@openeuler.org>",
        "Date": "Wed, 24 Feb 2021 09:28:53 +0800",
        "Message-ID": "<1614130139-42926-8-git-send-email-oulijun@huawei.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1614130139-42926-1-git-send-email-oulijun@huawei.com>",
        "References": "<1614130139-42926-1-git-send-email-oulijun@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 07/13] net/hns3: support PF on electrical net\n device",
        "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 normal operation of electrical interface devices depends on the\ninitialization and configuration of the PHY chip. The task of driving\nthe PHY chip is implemented in some firmware versions. If firmware\nsupports the phy driver, it will report a capability flag to driver\nin probing process. The driver determines whether to support electrical\ndevice based on the capability bit. If supported, the driver set a flag\nindicating that the firmware takes over the PHY, and then the firmware\nintializes the PHY.\n\nThis patch supports the query of link status and link info, and existing\nbasic features for electrical device.\n\nSigned-off-by: Huisong Li <lihuisong@huawei.com>\nSigned-off-by: Lijun Ou <oulijun@huawei.com>\n---\n doc/guides/rel_notes/release_21_05.rst |   1 +\n drivers/net/hns3/hns3_cmd.h            |  37 +++++++++++\n drivers/net/hns3/hns3_ethdev.c         | 115 +++++++++++++++++++++++++++++++--\n drivers/net/hns3/hns3_ethdev.h         |   5 ++\n 4 files changed, 152 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst\nindex 13e3633..07a61aa 100644\n--- a/doc/guides/rel_notes/release_21_05.rst\n+++ b/doc/guides/rel_notes/release_21_05.rst\n@@ -64,6 +64,7 @@ New Features\n \n   * Added support for module EEPROM dumping.\n   * Added support for freeing Tx mbuf on demand.\n+  * Added support for electrical port in Kunpeng930.\n \n Removed Items\n -------------\ndiff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h\nindex 93bfa74..7f567cb 100644\n--- a/drivers/net/hns3/hns3_cmd.h\n+++ b/drivers/net/hns3/hns3_cmd.h\n@@ -222,6 +222,8 @@ enum hns3_opcode_type {\n \n \t/* Firmware stats command */\n \tHNS3_OPC_FIRMWARE_COMPAT_CFG    = 0x701A,\n+\t/* Firmware control phy command */\n+\tHNS3_OPC_PHY_PARAM_CFG          = 0x7025,\n \n \t/* SFP command */\n \tHNS3_OPC_GET_SFP_EEPROM         = 0x7100,\n@@ -659,11 +661,46 @@ enum hns3_promisc_type {\n \n #define HNS3_LINK_EVENT_REPORT_EN_B\t0\n #define HNS3_NCSI_ERROR_REPORT_EN_B\t1\n+#define HNS3_FIRMWARE_PHY_DRIVER_EN_B\t2\n struct hns3_firmware_compat_cmd {\n \tuint32_t compat;\n \tuint8_t rsv[20];\n };\n \n+/* Bitmap flags in supported, advertising and lp_advertising */\n+#define HNS3_PHY_LINK_SPEED_10M_HD_BIT\t\tBIT(0)\n+#define HNS3_PHY_LINK_SPEED_10M_BIT\t\tBIT(1)\n+#define HNS3_PHY_LINK_SPEED_100M_HD_BIT\t\tBIT(2)\n+#define HNS3_PHY_LINK_SPEED_100M_BIT\t\tBIT(3)\n+#define HNS3_PHY_LINK_MODE_AUTONEG_BIT\t\tBIT(6)\n+#define HNS3_PHY_LINK_MODE_PAUSE_BIT\t\tBIT(13)\n+#define HNS3_PHY_LINK_MODE_ASYM_PAUSE_BIT\tBIT(14)\n+\n+#define HNS3_PHY_PARAM_CFG_BD_NUM\t2\n+struct hns3_phy_params_bd0_cmd {\n+\tuint32_t speed;\n+#define HNS3_PHY_DUPLEX_CFG_B\t\t0\n+\tuint8_t duplex;\n+#define HNS3_PHY_AUTONEG_CFG_B\t0\n+\tuint8_t autoneg;\n+\tuint8_t eth_tp_mdix;\n+\tuint8_t eth_tp_mdix_ctrl;\n+\tuint8_t port;\n+\tuint8_t transceiver;\n+\tuint8_t phy_address;\n+\tuint8_t rsv;\n+\tuint32_t supported;\n+\tuint32_t advertising;\n+\tuint32_t lp_advertising;\n+};\n+\n+struct hns3_phy_params_bd1_cmd {\n+\tuint8_t master_slave_cfg;\n+\tuint8_t master_slave_state;\n+\tuint8_t rsv1[2];\n+\tuint32_t rsv2[5];\n+};\n+\n #define HNS3_MAC_TX_EN_B\t\t6\n #define HNS3_MAC_RX_EN_B\t\t7\n #define HNS3_MAC_PAD_TX_B\t\t11\ndiff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c\nindex 4320695..a97dee4 100644\n--- a/drivers/net/hns3/hns3_ethdev.c\n+++ b/drivers/net/hns3/hns3_ethdev.c\n@@ -3090,6 +3090,37 @@ hns3_get_capability(struct hns3_hw *hw)\n }\n \n static int\n+hns3_check_media_type(struct hns3_hw *hw, uint8_t media_type)\n+{\n+\tint ret;\n+\n+\tswitch (media_type) {\n+\tcase HNS3_MEDIA_TYPE_COPPER:\n+\t\tif (!hns3_dev_copper_supported(hw)) {\n+\t\t\tPMD_INIT_LOG(ERR,\n+\t\t\t\t     \"Media type is copper, not supported.\");\n+\t\t\tret = -EOPNOTSUPP;\n+\t\t} else {\n+\t\t\tret = 0;\n+\t\t}\n+\t\tbreak;\n+\tcase HNS3_MEDIA_TYPE_FIBER:\n+\t\tret = 0;\n+\t\tbreak;\n+\tcase HNS3_MEDIA_TYPE_BACKPLANE:\n+\t\tPMD_INIT_LOG(ERR, \"Media type is Backplane, not supported.\");\n+\t\tret = -EOPNOTSUPP;\n+\t\tbreak;\n+\tdefault:\n+\t\tPMD_INIT_LOG(ERR, \"Unknown media type = %u!\", media_type);\n+\t\tret = -EINVAL;\n+\t\tbreak;\n+\t}\n+\n+\treturn ret;\n+}\n+\n+static int\n hns3_get_board_configuration(struct hns3_hw *hw)\n {\n \tstruct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);\n@@ -3103,11 +3134,9 @@ hns3_get_board_configuration(struct hns3_hw *hw)\n \t\treturn ret;\n \t}\n \n-\tif (cfg.media_type == HNS3_MEDIA_TYPE_COPPER &&\n-\t    !hns3_dev_copper_supported(hw)) {\n-\t\tPMD_INIT_LOG(ERR, \"media type is copper, not supported.\");\n-\t\treturn -EOPNOTSUPP;\n-\t}\n+\tret = hns3_check_media_type(hw, cfg.media_type);\n+\tif (ret)\n+\t\treturn ret;\n \n \thw->mac.media_type = cfg.media_type;\n \thw->rss_size_max = cfg.rss_size_max;\n@@ -3952,6 +3981,8 @@ hns3_firmware_compat_config(struct hns3_hw *hw, bool is_init)\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@@ -4429,6 +4460,78 @@ hns3_update_fiber_link_info(struct hns3_hw *hw)\n \treturn hns3_cfg_mac_speed_dup(hw, speed, ETH_LINK_FULL_DUPLEX);\n }\n \n+static void\n+hns3_parse_phy_params(struct hns3_cmd_desc *desc, struct hns3_mac *mac)\n+{\n+\tstruct hns3_phy_params_bd0_cmd *req;\n+\n+\treq = (struct hns3_phy_params_bd0_cmd *)desc[0].data;\n+\tmac->link_speed = rte_le_to_cpu_32(req->speed);\n+\tmac->link_duplex = hns3_get_bit(req->duplex,\n+\t\t\t\t\t   HNS3_PHY_DUPLEX_CFG_B);\n+\tmac->link_autoneg = hns3_get_bit(req->autoneg,\n+\t\t\t\t\t   HNS3_PHY_AUTONEG_CFG_B);\n+\tmac->supported_capa = rte_le_to_cpu_32(req->supported);\n+\tmac->advertising = rte_le_to_cpu_32(req->advertising);\n+\tmac->lp_advertising = rte_le_to_cpu_32(req->lp_advertising);\n+\tmac->support_autoneg = !!(mac->supported_capa &\n+\t\t\t\tHNS3_PHY_LINK_MODE_AUTONEG_BIT);\n+}\n+\n+static int\n+hns3_get_phy_params(struct hns3_hw *hw, struct hns3_mac *mac)\n+{\n+\tstruct hns3_cmd_desc desc[HNS3_PHY_PARAM_CFG_BD_NUM];\n+\tuint16_t i;\n+\tint ret;\n+\n+\tfor (i = 0; i < HNS3_PHY_PARAM_CFG_BD_NUM - 1; i++) {\n+\t\thns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_PHY_PARAM_CFG,\n+\t\t\t\t\t  true);\n+\t\tdesc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT);\n+\t}\n+\thns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_PHY_PARAM_CFG, true);\n+\n+\tret = hns3_cmd_send(hw, desc, HNS3_PHY_PARAM_CFG_BD_NUM);\n+\tif (ret) {\n+\t\thns3_err(hw, \"get phy parameters failed, ret = %d.\", ret);\n+\t\treturn ret;\n+\t}\n+\n+\thns3_parse_phy_params(desc, mac);\n+\n+\treturn 0;\n+}\n+\n+static int\n+hns3_update_phy_link_info(struct hns3_hw *hw)\n+{\n+\tstruct hns3_mac *mac = &hw->mac;\n+\tstruct hns3_mac mac_info;\n+\tint ret;\n+\n+\tmemset(&mac_info, 0, sizeof(struct hns3_mac));\n+\tret = hns3_get_phy_params(hw, &mac_info);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tif (mac_info.link_speed != mac->link_speed) {\n+\t\tret = hns3_port_shaper_update(hw, mac_info.link_speed);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n+\tmac->link_speed = mac_info.link_speed;\n+\tmac->link_duplex = mac_info.link_duplex;\n+\tmac->link_autoneg = mac_info.link_autoneg;\n+\tmac->supported_capa = mac_info.supported_capa;\n+\tmac->advertising = mac_info.advertising;\n+\tmac->lp_advertising = mac_info.lp_advertising;\n+\tmac->support_autoneg = mac_info.support_autoneg;\n+\n+\treturn 0;\n+}\n+\n static int\n hns3_update_link_info(struct rte_eth_dev *eth_dev)\n {\n@@ -4437,7 +4540,7 @@ hns3_update_link_info(struct rte_eth_dev *eth_dev)\n \tint ret = 0;\n \n \tif (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER)\n-\t\treturn 0;\n+\t\tret = hns3_update_phy_link_info(hw);\n \telse if (hw->mac.media_type == HNS3_MEDIA_TYPE_FIBER)\n \t\tret = hns3_update_fiber_link_info(hw);\n \ndiff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h\nindex 5299dd8..c495802 100644\n--- a/drivers/net/hns3/hns3_ethdev.h\n+++ b/drivers/net/hns3/hns3_ethdev.h\n@@ -180,6 +180,11 @@ struct hns3_mac {\n \tuint8_t link_autoneg : 1; /* ETH_LINK_[AUTONEG/FIXED] */\n \tuint8_t link_status  : 1; /* ETH_LINK_[DOWN/UP] */\n \tuint32_t link_speed;      /* ETH_SPEED_NUM_ */\n+\tuint32_t supported_capa;  /* supported capability for current media */\n+\tuint32_t advertising;     /* advertised capability in the local part */\n+\t/* advertised capability in the link partner */\n+\tuint32_t lp_advertising;\n+\tuint8_t support_autoneg;\n };\n \n struct hns3_fake_queue_data {\n",
    "prefixes": [
        "07/13"
    ]
}