get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 66402,
    "url": "http://patches.dpdk.org/api/patches/66402/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200309093243.63204-5-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": "<20200309093243.63204-5-huwei013@chinasoftinc.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200309093243.63204-5-huwei013@chinasoftinc.com",
    "date": "2020-03-09T09:32:42",
    "name": "[v2,4/5] net/hns3: support promiscuous and allmulticast mode for VF",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "d29989796c761f966ad58ffcbbda4a7fb2ed7701",
    "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/20200309093243.63204-5-huwei013@chinasoftinc.com/mbox/",
    "series": [
        {
            "id": 8836,
            "url": "http://patches.dpdk.org/api/series/8836/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=8836",
            "date": "2020-03-09T09:32:39",
            "name": "misc updates and fixes for hns3 PMD driver",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/8836/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/66402/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/66402/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 DE2B9A052E;\n\tMon,  9 Mar 2020 10:33:58 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 5349F1C08D;\n\tMon,  9 Mar 2020 10:33:27 +0100 (CET)",
            "from incedge.chinasoftinc.com (unknown [114.113.233.8])\n by dpdk.org (Postfix) with ESMTP id 72B5A1C021\n for <dev@dpdk.org>; Mon,  9 Mar 2020 10:33:21 +0100 (CET)",
            "from mail.chinasoftinc.com (inccas001.ito.icss [10.168.0.51]) by\n incedge.chinasoftinc.com with ESMTP id 8S1RFYc2W99nUx2r (version=TLSv1\n cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO) for <dev@dpdk.org>;\n Mon, 09 Mar 2020 17:32:50 +0800 (CST)",
            "from localhost.localdomain (114.119.4.74) by INCCAS001.ito.icss\n (10.168.0.60) with Microsoft SMTP Server id 14.3.487.0; Mon, 9 Mar 2020\n 17:32:49 +0800"
        ],
        "X-ASG-Debug-ID": "1583746368-0a3dd1404a03530005-TfluYd",
        "X-Barracuda-Envelope-From": "huwei013@chinasoftinc.com",
        "X-Barracuda-RBL-Trusted-Forwarder": [
            "10.168.0.51",
            "10.168.0.60"
        ],
        "X-ASG-Whitelist": "Client",
        "From": "\"Wei Hu (Xavier)\" <huwei013@chinasoftinc.com>",
        "To": "<dev@dpdk.org>",
        "Date": "Mon, 9 Mar 2020 17:32:42 +0800",
        "X-ASG-Orig-Subj": "[PATCH v2 4/5] net/hns3: support promiscuous and allmulticast\n mode for VF",
        "Message-ID": "<20200309093243.63204-5-huwei013@chinasoftinc.com>",
        "X-Mailer": "git-send-email 2.23.0",
        "In-Reply-To": "<20200309093243.63204-1-huwei013@chinasoftinc.com>",
        "References": "<20200309093243.63204-1-huwei013@chinasoftinc.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[114.119.4.74]",
        "X-Barracuda-Connect": "inccas001.ito.icss[10.168.0.51]",
        "X-Barracuda-Start-Time": "1583746370",
        "X-Barracuda-Encrypted": "ECDHE-RSA-AES256-SHA",
        "X-Barracuda-URL": "https://incspam.chinasofti.com:443/cgi-mod/mark.cgi",
        "X-Virus-Scanned": "by bsmtpd at chinasoftinc.com",
        "X-Barracuda-Scan-Msg-Size": "10369",
        "Subject": "[dpdk-dev] [PATCH v2 4/5] net/hns3: support promiscuous and\n\tallmulticast mode for VF",
        "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: Chengchang Tang <tangchengchang@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 promiscuous and allmulticast mode support for hns3 VF PMD\ndriver.\n1) The promiscuous/allmulticast mode can be configured successfully only\n   based on the trusted VF device. If based on the non trusted VF device,\n   configuring promiscuous/allmulticast mode will fail. The hns3 VF device\n   can be confiruged as trusted device by hns3 PF kernel ethdev driver on\n   the host by \"ip link set <eth num> vf <vf id> turst on\" command.\n2) After the promiscuous mode is configured successfully, hns3 VF PMD\n   driver can receive the ingress and outgoing traffic. In the words, all\n   the ingress packets, all the packets sent from the PF and other VFs on\n   the same physical port.\n3) Note: Because of the hardware constraints, By default vlan filter is\n   enabled and couldn't be turned off based on VF device, so vlan filter\n   is still effective even in promiscuous mode. If upper applications\n   don't call rte_eth_dev_vlan_filter API function to set vlan based on\n   VF device, hns3 VF PMD driver will can't receive the packets with vlan\n   tag in promiscuoue mode.\n\nSigned-off-by: Chengchang Tang <tangchengchang@huawei.com>\nSigned-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>\n---\nv1 -> v2:\n\tAdd Promiscuous and Allmulticast mode to hns3_vf.ini.\n---\n doc/guides/nics/features/hns3_vf.ini |   2 +\n drivers/net/hns3/hns3_ethdev_vf.c    | 117 +++++++++++++++++++++++++--\n drivers/net/hns3/hns3_mbx.c          |  23 ++++++\n drivers/net/hns3/hns3_mbx.h          |   2 +\n 4 files changed, 139 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/doc/guides/nics/features/hns3_vf.ini b/doc/guides/nics/features/hns3_vf.ini\nindex e4e77380f..80773ac90 100644\n--- a/doc/guides/nics/features/hns3_vf.ini\n+++ b/doc/guides/nics/features/hns3_vf.ini\n@@ -9,6 +9,8 @@ Rx interrupt         = Y\n MTU update           = Y\n Jumbo frame          = Y\n TSO                  = Y\n+Promiscuous mode     = Y\n+Allmulticast mode    = Y\n Unicast MAC filter   = Y\n Multicast MAC filter = Y\n RSS hash             = Y\ndiff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c\nindex 6b787133f..28755bf4f 100644\n--- a/drivers/net/hns3/hns3_ethdev_vf.c\n+++ b/drivers/net/hns3/hns3_ethdev_vf.c\n@@ -410,7 +410,8 @@ hns3vf_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del)\n }\n \n static int\n-hns3vf_set_promisc_mode(struct hns3_hw *hw, bool en_bc_pmc)\n+hns3vf_set_promisc_mode(struct hns3_hw *hw, bool en_bc_pmc,\n+\t\t\tbool en_uc_pmc, bool en_mc_pmc)\n {\n \tstruct hns3_mbx_vf_to_pf_cmd *req;\n \tstruct hns3_cmd_desc desc;\n@@ -418,17 +419,115 @@ hns3vf_set_promisc_mode(struct hns3_hw *hw, bool en_bc_pmc)\n \n \treq = (struct hns3_mbx_vf_to_pf_cmd *)desc.data;\n \n+\t/*\n+\t * The hns3 VF PMD driver depends on the hns3 PF kernel ethdev driver,\n+\t * so there are some features for promiscuous/allmulticast mode in hns3\n+\t * VF PMD driver as below:\n+\t * 1. The promiscuous/allmulticast mode can be configured successfully\n+\t *    only based on the trusted VF device. If based on the non trusted\n+\t *    VF device, configuring promiscuous/allmulticast mode will fail.\n+\t *    The hns3 VF device can be confiruged as trusted device by hns3 PF\n+\t *    kernel ethdev driver on the host by the following command:\n+\t *      \"ip link set <eth num> vf <vf id> turst on\"\n+\t * 2. After the promiscuous mode is configured successfully, hns3 VF PMD\n+\t *    driver can receive the ingress and outgoing traffic. In the words,\n+\t *    all the ingress packets, all the packets sent from the PF and\n+\t *    other VFs on the same physical port.\n+\t * 3. Note: Because of the hardware constraints, By default vlan filter\n+\t *    is enabled and couldn't be turned off based on VF device, so vlan\n+\t *    filter is still effective even in promiscuous mode. If upper\n+\t *    applications don't call rte_eth_dev_vlan_filter API function to\n+\t *    set vlan based on VF device, hns3 VF PMD driver will can't receive\n+\t *    the packets with vlan tag in promiscuoue mode.\n+\t */\n \thns3_cmd_setup_basic_desc(&desc, HNS3_OPC_MBX_VF_TO_PF, false);\n \treq->msg[0] = HNS3_MBX_SET_PROMISC_MODE;\n \treq->msg[1] = en_bc_pmc ? 1 : 0;\n+\treq->msg[2] = en_uc_pmc ? 1 : 0;\n+\treq->msg[3] = en_mc_pmc ? 1 : 0;\n \n \tret = hns3_cmd_send(hw, &desc, 1);\n \tif (ret)\n-\t\thns3_err(hw, \"Set promisc mode fail, status is %d\", ret);\n+\t\thns3_err(hw, \"Set promisc mode fail, ret = %d\", ret);\n+\n+\treturn ret;\n+}\n+\n+static int\n+hns3vf_dev_promiscuous_enable(struct rte_eth_dev *dev)\n+{\n+\tstruct hns3_adapter *hns = dev->data->dev_private;\n+\tstruct hns3_hw *hw = &hns->hw;\n+\tint ret;\n+\n+\tret = hns3vf_set_promisc_mode(hw, true, true, true);\n+\tif (ret)\n+\t\thns3_err(hw, \"Failed to enable promiscuous mode, ret = %d\",\n+\t\t\tret);\n+\treturn ret;\n+}\n+\n+static int\n+hns3vf_dev_promiscuous_disable(struct rte_eth_dev *dev)\n+{\n+\tbool allmulti = dev->data->all_multicast ? true : false;\n+\tstruct hns3_adapter *hns = dev->data->dev_private;\n+\tstruct hns3_hw *hw = &hns->hw;\n+\tint ret;\n+\n+\tret = hns3vf_set_promisc_mode(hw, true, false, allmulti);\n+\tif (ret)\n+\t\thns3_err(hw, \"Failed to disable promiscuous mode, ret = %d\",\n+\t\t\tret);\n+\treturn ret;\n+}\n+\n+static int\n+hns3vf_dev_allmulticast_enable(struct rte_eth_dev *dev)\n+{\n+\tstruct hns3_adapter *hns = dev->data->dev_private;\n+\tstruct hns3_hw *hw = &hns->hw;\n+\tint ret;\n+\n+\tif (dev->data->promiscuous)\n+\t\treturn 0;\n+\n+\tret = hns3vf_set_promisc_mode(hw, true, false, true);\n+\tif (ret)\n+\t\thns3_err(hw, \"Failed to enable allmulticast mode, ret = %d\",\n+\t\t\tret);\n+\treturn ret;\n+}\n+\n+static int\n+hns3vf_dev_allmulticast_disable(struct rte_eth_dev *dev)\n+{\n+\tstruct hns3_adapter *hns = dev->data->dev_private;\n+\tstruct hns3_hw *hw = &hns->hw;\n+\tint ret;\n+\n+\tif (dev->data->promiscuous)\n+\t\treturn 0;\n \n+\tret = hns3vf_set_promisc_mode(hw, true, false, false);\n+\tif (ret)\n+\t\thns3_err(hw, \"Failed to disable allmulticast mode, ret = %d\",\n+\t\t\tret);\n \treturn ret;\n }\n \n+static int\n+hns3vf_restore_promisc(struct hns3_adapter *hns)\n+{\n+\tstruct hns3_hw *hw = &hns->hw;\n+\tbool allmulti = hw->data->all_multicast ? true : false;\n+\n+\tif (hw->data->promiscuous)\n+\t\treturn hns3vf_set_promisc_mode(hw, true, true, true);\n+\n+\treturn hns3vf_set_promisc_mode(hw, true, false, allmulti);\n+}\n+\n static int\n hns3vf_bind_ring_with_vector(struct hns3_hw *hw, uint8_t vector_id,\n \t\t\t     bool mmap, enum hns3_ring_type queue_type,\n@@ -1250,7 +1349,7 @@ hns3vf_init_hardware(struct hns3_adapter *hns)\n \tuint16_t mtu = hw->data->mtu;\n \tint ret;\n \n-\tret = hns3vf_set_promisc_mode(hw, true);\n+\tret = hns3vf_set_promisc_mode(hw, true, false, false);\n \tif (ret)\n \t\treturn ret;\n \n@@ -1280,7 +1379,7 @@ hns3vf_init_hardware(struct hns3_adapter *hns)\n \treturn 0;\n \n err_init_hardware:\n-\t(void)hns3vf_set_promisc_mode(hw, false);\n+\t(void)hns3vf_set_promisc_mode(hw, false, false, false);\n \treturn ret;\n }\n \n@@ -1413,7 +1512,7 @@ hns3vf_uninit_vf(struct rte_eth_dev *eth_dev)\n \n \thns3_rss_uninit(hns);\n \t(void)hns3vf_set_alive(hw, false);\n-\t(void)hns3vf_set_promisc_mode(hw, false);\n+\t(void)hns3vf_set_promisc_mode(hw, false, false, false);\n \thns3vf_disable_irq0(hw);\n \trte_intr_disable(&pci_dev->intr_handle);\n \thns3_intr_unregister(&pci_dev->intr_handle, hns3vf_interrupt_handler,\n@@ -1896,6 +1995,10 @@ hns3vf_restore_conf(struct hns3_adapter *hns)\n \tif (ret)\n \t\tgoto err_mc_mac;\n \n+\tret = hns3vf_restore_promisc(hns);\n+\tif (ret)\n+\t\tgoto err_vlan_table;\n+\n \tret = hns3vf_restore_vlan_conf(hns);\n \tif (ret)\n \t\tgoto err_vlan_table;\n@@ -2048,6 +2151,10 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = {\n \t.dev_stop           = hns3vf_dev_stop,\n \t.dev_close          = hns3vf_dev_close,\n \t.mtu_set            = hns3vf_dev_mtu_set,\n+\t.promiscuous_enable = hns3vf_dev_promiscuous_enable,\n+\t.promiscuous_disable = hns3vf_dev_promiscuous_disable,\n+\t.allmulticast_enable = hns3vf_dev_allmulticast_enable,\n+\t.allmulticast_disable = hns3vf_dev_allmulticast_disable,\n \t.stats_get          = hns3_stats_get,\n \t.stats_reset        = hns3_stats_reset,\n \t.xstats_get         = hns3_dev_xstats_get,\ndiff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c\nindex 0d03f5064..b03a3d6a1 100644\n--- a/drivers/net/hns3/hns3_mbx.c\n+++ b/drivers/net/hns3/hns3_mbx.c\n@@ -324,6 +324,21 @@ hns3_handle_link_change_event(struct hns3_hw *hw,\n \thns3_update_link_status(hw);\n }\n \n+static void\n+hns3_handle_promisc_info(struct hns3_hw *hw, uint16_t promisc_en)\n+{\n+\tif (!promisc_en) {\n+\t\t/*\n+\t\t * When promisc/allmulti mode is closed by the hns3 PF kernel\n+\t\t * ethdev driver for untrusted, modify VF's related status.\n+\t\t */\n+\t\thns3_warn(hw, \"Promisc mode will be closed by host for being \"\n+\t\t\t      \"untrusted.\");\n+\t\thw->data->promiscuous = 0;\n+\t\thw->data->all_multicast = 0;\n+\t}\n+}\n+\n void\n hns3_dev_handle_mbx_msg(struct hns3_hw *hw)\n {\n@@ -380,6 +395,14 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw)\n \t\tcase HNS3_MBX_PUSH_LINK_STATUS:\n \t\t\thns3_handle_link_change_event(hw, req);\n \t\t\tbreak;\n+\t\tcase HNS3_MBX_PUSH_PROMISC_INFO:\n+\t\t\t/*\n+\t\t\t * When the trust status of VF device changed by the\n+\t\t\t * hns3 PF kernel driver, VF driver will receive this\n+\t\t\t * mailbox message from PF driver.\n+\t\t\t */\n+\t\t\thns3_handle_promisc_info(hw, req->msg[1]);\n+\t\t\tbreak;\n \t\tdefault:\n \t\t\thns3_err(hw,\n \t\t\t\t \"VF received unsupported(%d) mbx msg from PF\",\ndiff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h\nindex b01eaacc3..d6d70f686 100644\n--- a/drivers/net/hns3/hns3_mbx.h\n+++ b/drivers/net/hns3/hns3_mbx.h\n@@ -40,6 +40,8 @@ enum HNS3_MBX_OPCODE {\n \tHNS3_MBX_SET_MTU,               /* (VF -> PF) set mtu */\n \tHNS3_MBX_GET_QID_IN_PF,         /* (VF -> PF) get queue id in pf */\n \n+\tHNS3_MBX_PUSH_PROMISC_INFO = 36, /* (PF -> VF) push vf promisc info */\n+\n \tHNS3_MBX_HANDLE_VF_TBL = 38,    /* (VF -> PF) store/clear hw cfg tbl */\n \tHNS3_MBX_GET_RING_VECTOR_MAP,   /* (VF -> PF) get ring-to-vector map */\n \tHNS3_MBX_PUSH_LINK_STATUS = 201, /* (IMP -> PF) get port link status */\n",
    "prefixes": [
        "v2",
        "4/5"
    ]
}