get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 64317,
    "url": "http://patches.dpdk.org/api/patches/64317/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200109031559.63194-3-huwei013@chinasoftinc.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": "<20200109031559.63194-3-huwei013@chinasoftinc.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200109031559.63194-3-huwei013@chinasoftinc.com",
    "date": "2020-01-09T03:15:50",
    "name": "[02/11] net/hns3: support setting VF MAC address by PF driver",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "71406f1b1be9af37abd06e41f800c64982f47d99",
    "submitter": {
        "id": 1537,
        "url": "http://patches.dpdk.org/api/people/1537/?format=api",
        "name": "Wei Hu (Xavier)",
        "email": "huwei013@chinasoftinc.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/20200109031559.63194-3-huwei013@chinasoftinc.com/mbox/",
    "series": [
        {
            "id": 8023,
            "url": "http://patches.dpdk.org/api/series/8023/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=8023",
            "date": "2020-01-09T03:15:48",
            "name": "misc updates and fixes for hns3 PMD driver",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/8023/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/64317/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/64317/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 28601A04F3;\n\tThu,  9 Jan 2020 04:24:19 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id E47DA1DB54;\n\tThu,  9 Jan 2020 04:23:45 +0100 (CET)",
            "from incedge.chinasoftinc.com (unknown [114.113.233.8])\n by dpdk.org (Postfix) with ESMTP id 94DBD1DB35\n for <dev@dpdk.org>; Thu,  9 Jan 2020 04:23:38 +0100 (CET)",
            "from mail.chinasoftinc.com (inccas002.ito.icss [10.168.0.52]) by\n incedge.chinasoftinc.com with ESMTP id oTRPPeCprWN7rOQO (version=TLSv1\n cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO) for <dev@dpdk.org>;\n Thu, 09 Jan 2020 11:22:47 +0800 (CST)",
            "from localhost.localdomain (203.160.91.226) by INCCAS002.ito.icss\n (10.168.0.60) with Microsoft SMTP Server id 14.3.439.0; Thu, 9 Jan 2020\n 11:16:11 +0800"
        ],
        "X-ASG-Debug-ID": "1578539509-0a3dd116d0042b0012-TfluYd",
        "X-Barracuda-Envelope-From": "huwei013@chinasoftinc.com",
        "X-Barracuda-RBL-Trusted-Forwarder": [
            "10.168.0.52",
            "10.168.0.60"
        ],
        "X-ASG-Whitelist": "Client",
        "From": "\"Wei Hu (Xavier)\" <huwei013@chinasoftinc.com>",
        "To": "<dev@dpdk.org>",
        "Date": "Thu, 9 Jan 2020 11:15:50 +0800",
        "X-ASG-Orig-Subj": "[PATCH 02/11] net/hns3: support setting VF MAC address by PF\n driver",
        "Message-ID": "<20200109031559.63194-3-huwei013@chinasoftinc.com>",
        "X-Mailer": "git-send-email 2.23.0",
        "In-Reply-To": "<20200109031559.63194-1-huwei013@chinasoftinc.com>",
        "References": "<20200109031559.63194-1-huwei013@chinasoftinc.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[203.160.91.226]",
        "X-Barracuda-Connect": "inccas002.ito.icss[10.168.0.52]",
        "X-Barracuda-Start-Time": "1578540167",
        "X-Barracuda-Encrypted": "ECDHE-RSA-AES256-SHA",
        "X-Barracuda-URL": "https://spam.chinasoftinc.com:443/cgi-mod/mark.cgi",
        "X-Virus-Scanned": "by bsmtpd at chinasoftinc.com",
        "X-Barracuda-Scan-Msg-Size": "7163",
        "Subject": "[dpdk-dev] [PATCH 02/11] net/hns3: support setting VF MAC address\n\tby PF driver",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "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: \"Wei Hu (Xavier)\" <xavier.huwei@huawei.com>\n\nCurrently, we only support VF device is bound to vfio_pci or igb_uio and\nthen driven by DPDK driver when PF is driven by kernel mode hns3 ethdev\ndriver, VF is not supported when PF is driven by hns3 DPDK driver.\n\nThis patch adds support setting VF MAC address by hns3 PF kernel ethdev\ndriver on the host by \"ip link set ...\" command.\n1) If the hns3 PF kernel ethdev driver sets the MAC address for VF device\n   before the initialization of the related VF device, hns3 VF PMD driver\n   should get the MAC address from PF driver through mailbox and configure\n   hardware using this MAC address in the initialization. The hns3 VF PMD\n   driver get the MAC address form PF driver, if obtaining a non-zero MAC\n   address from mailbox, VF driver will configure hardware using it,\n   otherwise using a random MAC address in the initialization of VF device.\n2) If the hns3 PF kernel ethdev driver sets the MAC address for VF device\n   after the initialization of the related VF device, the PF driver will\n   notify VF driver to reset VF device to make the new MAC address\n   effective immediately. The hns3 VF PMD driver should check whether the\n   MAC address has been changed by the PF kernel netdevice driver, if\n   changed VF driver should configure hardware using the new MAC address\n   in the recovering hardware configuration stage of the reset process.\n3) When user has configured a mac address for VF device by\n   \"ip link set ...\" command based on the PF device, the hns3 PF kernel\n   ethdev driver does not allow VF driver to request reconfiguring a\n   different default mac address and return -EPREM to VF driver through\n   mailbox.\n\nSigned-off-by: Chengchang Tang <tangchengchang@huawei.com>\nSigned-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>\nSigned-off-by: Hongbo Zheng <zhenghongbo3@huawei.com>\n---\n drivers/net/hns3/hns3_ethdev_vf.c | 108 ++++++++++++++++++++++++++++--\n 1 file changed, 102 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c\nindex 71e358e81..92cf7ee99 100644\n--- a/drivers/net/hns3/hns3_ethdev_vf.c\n+++ b/drivers/net/hns3/hns3_ethdev_vf.c\n@@ -208,12 +208,27 @@ hns3vf_set_default_mac_addr(struct rte_eth_dev *dev,\n \n \tret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_UNICAST,\n \t\t\t\tHNS3_MBX_MAC_VLAN_UC_MODIFY, addr_bytes,\n-\t\t\t\tHNS3_TWO_ETHER_ADDR_LEN, false, NULL, 0);\n+\t\t\t\tHNS3_TWO_ETHER_ADDR_LEN, true, NULL, 0);\n \tif (ret) {\n-\t\trte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,\n-\t\t\t\t      mac_addr);\n-\t\thns3_err(hw, \"Failed to set mac addr(%s) for vf: %d\", mac_str,\n-\t\t\t ret);\n+\t\t/*\n+\t\t * The hns3 VF PMD driver depends on the hns3 PF kernel ethdev\n+\t\t * driver. When user has configured a MAC address for VF device\n+\t\t * by \"ip link set ...\" command based on the PF device, the hns3\n+\t\t * PF kernel ethdev driver does not allow VF driver to request\n+\t\t * reconfiguring a different default MAC address, and return\n+\t\t * -EPREM to VF driver through mailbox.\n+\t\t */\n+\t\tif (ret == -EPERM) {\n+\t\t\trte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,\n+\t\t\t\t\t      old_addr);\n+\t\t\thns3_warn(hw, \"Has permanet mac addr(%s) for vf\",\n+\t\t\t\t  mac_str);\n+\t\t} else {\n+\t\t\trte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,\n+\t\t\t\t\t      mac_addr);\n+\t\t\thns3_err(hw, \"Failed to set mac addr(%s) for vf: %d\",\n+\t\t\t\t mac_str, ret);\n+\t\t}\n \t}\n \n \trte_ether_addr_copy(mac_addr,\n@@ -784,6 +799,24 @@ hns3vf_get_tc_info(struct hns3_hw *hw)\n \treturn 0;\n }\n \n+static int\n+hns3vf_get_host_mac_addr(struct hns3_hw *hw)\n+{\n+\tuint8_t host_mac[RTE_ETHER_ADDR_LEN];\n+\tint ret;\n+\n+\tret = hns3_send_mbx_msg(hw, HNS3_MBX_GET_MAC_ADDR, 0, NULL, 0,\n+\t\t\t\ttrue, host_mac, RTE_ETHER_ADDR_LEN);\n+\tif (ret) {\n+\t\thns3_err(hw, \"Failed to get mac addr from PF: %d\", ret);\n+\t\treturn ret;\n+\t}\n+\n+\tmemcpy(hw->mac.mac_addr, host_mac, RTE_ETHER_ADDR_LEN);\n+\n+\treturn 0;\n+}\n+\n static int\n hns3vf_get_configuration(struct hns3_hw *hw)\n {\n@@ -801,6 +834,11 @@ hns3vf_get_configuration(struct hns3_hw *hw)\n \tif (ret)\n \t\treturn ret;\n \n+\t/* Get user defined VF MAC addr from PF */\n+\tret = hns3vf_get_host_mac_addr(hw);\n+\tif (ret)\n+\t\treturn ret;\n+\n \t/* Get tc configuration from PF */\n \treturn hns3vf_get_tc_info(hw);\n }\n@@ -1170,7 +1208,20 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev)\n \t\tgoto err_get_config;\n \t}\n \n-\trte_eth_random_addr(hw->mac.mac_addr); /* Generate a random mac addr */\n+\t/*\n+\t * The hns3 PF ethdev driver in kernel support setting VF MAC address\n+\t * on the host by \"ip link set ...\" command. To avoid some incorrect\n+\t * scenes, for example, hns3 VF PMD driver fails to receive and send\n+\t * packets after user configure the MAC address by using the\n+\t * \"ip link set ...\" command, hns3 VF PMD driver keep the same MAC\n+\t * address strategy as the hns3 kernel ethdev driver in the\n+\t * initialization. If user configure a MAC address by the ip command\n+\t * for VF device, then hns3 VF PMD driver will start with it, otherwise\n+\t * start with a random MAC address in the initialization.\n+\t */\n+\tret = rte_is_zero_ether_addr((struct rte_ether_addr *)hw->mac.mac_addr);\n+\tif (ret)\n+\t\trte_eth_random_addr(hw->mac.mac_addr);\n \n \tret = hns3vf_clear_vport_list(hw);\n \tif (ret) {\n@@ -1663,12 +1714,57 @@ hns3vf_start_service(struct hns3_adapter *hns)\n \treturn 0;\n }\n \n+static int\n+hns3vf_check_default_mac_change(struct hns3_hw *hw)\n+{\n+\tchar mac_str[RTE_ETHER_ADDR_FMT_SIZE];\n+\tstruct rte_ether_addr *hw_mac;\n+\tint ret;\n+\n+\t/*\n+\t * The hns3 PF ethdev driver in kernel support setting VF MAC address\n+\t * on the host by \"ip link set ...\" command. If the hns3 PF kernel\n+\t * ethdev driver sets the MAC address for VF device after the\n+\t * initialization of the related VF device, the PF driver will notify\n+\t * VF driver to reset VF device to make the new MAC address effective\n+\t * immediately. The hns3 VF PMD driver should check whether the MAC\n+\t * address has been changed by the PF kernel ethdev driver, if changed\n+\t * VF driver should configure hardware using the new MAC address in the\n+\t * recovering hardware configuration stage of the reset process.\n+\t */\n+\tret = hns3vf_get_host_mac_addr(hw);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\thw_mac = (struct rte_ether_addr *)hw->mac.mac_addr;\n+\tret = rte_is_zero_ether_addr(hw_mac);\n+\tif (ret)\n+\t\trte_ether_addr_copy(&hw->data->mac_addrs[0], hw_mac);\n+\telse {\n+\t\tret = rte_is_same_ether_addr(&hw->data->mac_addrs[0], hw_mac);\n+\t\tif (!ret) {\n+\t\t\trte_ether_addr_copy(hw_mac, &hw->data->mac_addrs[0]);\n+\t\t\trte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,\n+\t\t\t\t\t      &hw->data->mac_addrs[0]);\n+\t\t\thns3_warn(hw, \"Default MAC address has been changed to:\"\n+\t\t\t\t  \" %s by the host PF kernel ethdev driver\",\n+\t\t\t\t  mac_str);\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n static int\n hns3vf_restore_conf(struct hns3_adapter *hns)\n {\n \tstruct hns3_hw *hw = &hns->hw;\n \tint ret;\n \n+\tret = hns3vf_check_default_mac_change(hw);\n+\tif (ret)\n+\t\treturn ret;\n+\n \tret = hns3vf_configure_mac_addr(hns, false);\n \tif (ret)\n \t\treturn ret;\n",
    "prefixes": [
        "02/11"
    ]
}