get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1240374,
    "url": "http://patchwork.ozlabs.org/api/patches/1240374/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200218212206.1043785-1-jeffrey.t.kirsher@intel.com/",
    "project": {
        "id": 46,
        "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api",
        "name": "Intel Wired Ethernet development",
        "link_name": "intel-wired-lan",
        "list_id": "intel-wired-lan.osuosl.org",
        "list_email": "intel-wired-lan@osuosl.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20200218212206.1043785-1-jeffrey.t.kirsher@intel.com>",
    "list_archive_url": null,
    "date": "2020-02-18T21:22:06",
    "name": "[net-queue,v2] ice: Wait for VF to be reset/ready before configuration",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "1455f87fdf0a36ff5ac48c38d08cc00f36d7a18f",
    "submitter": {
        "id": 473,
        "url": "http://patchwork.ozlabs.org/api/people/473/?format=api",
        "name": "Kirsher, Jeffrey T",
        "email": "jeffrey.t.kirsher@intel.com"
    },
    "delegate": {
        "id": 68,
        "url": "http://patchwork.ozlabs.org/api/users/68/?format=api",
        "username": "jtkirshe",
        "first_name": "Jeff",
        "last_name": "Kirsher",
        "email": "jeffrey.t.kirsher@intel.com"
    },
    "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200218212206.1043785-1-jeffrey.t.kirsher@intel.com/mbox/",
    "series": [
        {
            "id": 159368,
            "url": "http://patchwork.ozlabs.org/api/series/159368/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=159368",
            "date": "2020-02-18T21:22:06",
            "name": "[net-queue,v2] ice: Wait for VF to be reset/ready before configuration",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/159368/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1240374/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1240374/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<intel-wired-lan-bounces@osuosl.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Authentication-Results": [
            "ozlabs.org; spf=pass (sender SPF authorized)\n\tsmtp.mailfrom=osuosl.org (client-ip=140.211.166.137;\n\thelo=fraxinus.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=intel.com"
        ],
        "Received": [
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 48MYhk3tJBz9sRY\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 19 Feb 2020 08:22:14 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 7B8A685B81;\n\tTue, 18 Feb 2020 21:22:12 +0000 (UTC)",
            "from fraxinus.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id g_weOhye_X2u; Tue, 18 Feb 2020 21:22:11 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 7B5F785BD3;\n\tTue, 18 Feb 2020 21:22:11 +0000 (UTC)",
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\tby ash.osuosl.org (Postfix) with ESMTP id 99F731BF5AE\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 18 Feb 2020 21:22:09 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 929B885BD3\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 18 Feb 2020 21:22:09 +0000 (UTC)",
            "from fraxinus.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id Oz6i1OD-mutX for <intel-wired-lan@lists.osuosl.org>;\n\tTue, 18 Feb 2020 21:22:08 +0000 (UTC)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby fraxinus.osuosl.org (Postfix) with ESMTPS id 8DD6285B81\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 18 Feb 2020 21:22:08 +0000 (UTC)",
            "from fmsmga008.fm.intel.com ([10.253.24.58])\n\tby fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t18 Feb 2020 13:22:08 -0800",
            "from jtkirshe-desk1.jf.intel.com ([134.134.177.76])\n\tby fmsmga008.fm.intel.com with ESMTP; 18 Feb 2020 13:22:08 -0800"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.70,458,1574150400\"; d=\"scan'208\";a=\"229601769\"",
        "From": "Jeff Kirsher <jeffrey.t.kirsher@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org",
        "Date": "Tue, 18 Feb 2020 13:22:06 -0800",
        "Message-Id": "<20200218212206.1043785-1-jeffrey.t.kirsher@intel.com>",
        "X-Mailer": "git-send-email 2.24.1",
        "MIME-Version": "1.0",
        "Subject": "[Intel-wired-lan] [net-queue v2] ice: Wait for VF to be reset/ready\n\tbefore configuration",
        "X-BeenThere": "intel-wired-lan@osuosl.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>",
        "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>",
        "List-Post": "<mailto:intel-wired-lan@osuosl.org>",
        "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>",
        "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>",
        "Cc": "Brett Creeley <brett.creeley@intel.com>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "intel-wired-lan-bounces@osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"
    },
    "content": "From: Brett Creeley <brett.creeley@intel.com>\n\nThe configuration/command below is failing when the VF in the xml\nfile is already bound to the host iavf driver.\n\npci_0000_af_0_0.xml:\n\n<interface type='hostdev' managed='yes'>\n<source>\n<address type='pci' domain='0x0000' bus='0xaf' slot='0x0' function='0x0'/>\n</source>\n<mac address='00:de:ad:00:11:01'/>\n</interface>\n\n> virsh attach-device domain_name pci_0000_af_0_0.xml\nerror: Failed to attach device from pci_0000_af_0_0.xml\nerror: Cannot set interface MAC/vlanid to 00:de:ad:00:11:01/0 for\n\tifname ens1f1 vf 0: Device or resource busy\n\nThis is failing because the VF has not been completely removed/reset\nafter being unbound (via the virsh command above) from the host iavf\ndriver and ice_set_vf_mac() checks if the VF is disabled before waiting\nfor the reset to finish.\n\nFix this by waiting for the VF remove/reset process to happen before\nchecking if the VF is disabled. Also, since many functions for VF\nadministration on the PF were more or less calling the same 3 functions\n(ice_wait_on_vf_reset(), ice_is_vf_disabled(), and ice_check_vf_init())\nmove these into the helper function ice_check_vf_ready_for_cfg(). Then\ncall this function in any flow that attempts to configure/query a VF\nfrom the PF.\n\nLastly, increase the maximum wait time in ice_wait_on_vf_reset() to\n800ms, and modify/add the #define(s) that determine the wait time.\nThis was done for robustness because in rare/stress cases VF removal can\ntake a max of ~800ms and previously the wait was a max of ~300ms.\n\nSigned-off-by: Brett Creeley <brett.creeley@intel.com>\n---\nv2: Original patch did not apply cleanly to my net-queue tree, so it had\n    to be applied by hand, this version applies cleanly to net-queue\n\n .../net/ethernet/intel/ice/ice_virtchnl_pf.c  | 123 ++++++++++--------\n .../net/ethernet/intel/ice/ice_virtchnl_pf.h  |   3 +-\n 2 files changed, 71 insertions(+), 55 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c\nindex 262714d5f54a..af3e37b71111 100644\n--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c\n+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c\n@@ -1873,6 +1873,48 @@ static int ice_vc_config_rss_lut(struct ice_vf *vf, u8 *msg)\n \t\t\t\t     NULL, 0);\n }\n \n+/**\n+ * ice_wait_on_vf_reset - poll to make sure a given VF is ready after reset\n+ * @vf: The VF being resseting\n+ *\n+ * The max poll time is about ~800ms, which is about the maximum time it takes\n+ * for a VF to be reset and/or a VF driver to be removed.\n+ */\n+static void ice_wait_on_vf_reset(struct ice_vf *vf)\n+{\n+\tint i;\n+\n+\tfor (i = 0; i < ICE_MAX_VF_RESET_TRIES; i++) {\n+\t\tif (test_bit(ICE_VF_STATE_INIT, vf->vf_states))\n+\t\t\tbreak;\n+\t\tmsleep(ICE_MAX_VF_RESET_SLEEP_MS);\n+\t}\n+}\n+\n+/**\n+ * ice_check_vf_ready_for_cfg - check if VF is ready to be configured/queried\n+ * @vf: VF to check if it's ready to be configured/queried\n+ *\n+ * The purpose of this function is to make sure the VF is not in reset, not\n+ * disabled, and initialized so it can be configured and/or queried by a host\n+ * administrator.\n+ */\n+static int ice_check_vf_ready_for_cfg(struct ice_vf *vf)\n+{\n+\tstruct ice_pf *pf;\n+\n+\tice_wait_on_vf_reset(vf);\n+\n+\tif (ice_is_vf_disabled(vf))\n+\t\treturn -EINVAL;\n+\n+\tpf = vf->pf;\n+\tif (ice_check_vf_init(pf, vf))\n+\t\treturn -EBUSY;\n+\n+\treturn 0;\n+}\n+\n /**\n  * ice_set_vf_spoofchk\n  * @netdev: network interface device structure\n@@ -1890,16 +1932,16 @@ int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena)\n \tenum ice_status status;\n \tstruct device *dev;\n \tstruct ice_vf *vf;\n-\tint ret = 0;\n+\tint ret;\n \n \tdev = ice_pf_to_dev(pf);\n \tif (ice_validate_vf_id(pf, vf_id))\n \t\treturn -EINVAL;\n \n \tvf = &pf->vf[vf_id];\n-\n-\tif (ice_check_vf_init(pf, vf))\n-\t\treturn -EBUSY;\n+\tret = ice_check_vf_ready_for_cfg(vf);\n+\tif (ret)\n+\t\treturn ret;\n \n \tvf_vsi = pf->vsi[vf->lan_vsi_idx];\n \tif (!vf_vsi) {\n@@ -2696,7 +2738,7 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,\n \tstruct ice_vsi *vsi;\n \tstruct device *dev;\n \tstruct ice_vf *vf;\n-\tint ret = 0;\n+\tint ret;\n \n \tdev = ice_pf_to_dev(pf);\n \tif (ice_validate_vf_id(pf, vf_id))\n@@ -2714,8 +2756,10 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,\n \n \tvf = &pf->vf[vf_id];\n \tvsi = pf->vsi[vf->lan_vsi_idx];\n-\tif (ice_check_vf_init(pf, vf))\n-\t\treturn -EBUSY;\n+\n+\tret = ice_check_vf_ready_for_cfg(vf);\n+\tif (ret)\n+\t\treturn ret;\n \n \tif (le16_to_cpu(vsi->info.pvid) == vlanprio) {\n \t\t/* duplicate request, so just return success */\n@@ -3236,23 +3280,6 @@ ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi)\n \treturn 0;\n }\n \n-/**\n- * ice_wait_on_vf_reset\n- * @vf: The VF being resseting\n- *\n- * Poll to make sure a given VF is ready after reset\n- */\n-static void ice_wait_on_vf_reset(struct ice_vf *vf)\n-{\n-\tint i;\n-\n-\tfor (i = 0; i < ICE_MAX_VF_RESET_WAIT; i++) {\n-\t\tif (test_bit(ICE_VF_STATE_INIT, vf->vf_states))\n-\t\t\tbreak;\n-\t\tmsleep(20);\n-\t}\n-}\n-\n /**\n  * ice_set_vf_mac\n  * @netdev: network interface device structure\n@@ -3265,29 +3292,21 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)\n {\n \tstruct ice_pf *pf = ice_netdev_to_pf(netdev);\n \tstruct ice_vf *vf;\n-\tint ret = 0;\n+\tint ret;\n \n \tif (ice_validate_vf_id(pf, vf_id))\n \t\treturn -EINVAL;\n \n-\tvf = &pf->vf[vf_id];\n-\t/* Don't set MAC on disabled VF */\n-\tif (ice_is_vf_disabled(vf))\n-\t\treturn -EINVAL;\n-\n-\t/* In case VF is in reset mode, wait until it is completed. Depending\n-\t * on factors like queue disabling routine, this could take ~250ms\n-\t */\n-\tice_wait_on_vf_reset(vf);\n-\n-\tif (ice_check_vf_init(pf, vf))\n-\t\treturn -EBUSY;\n-\n \tif (is_zero_ether_addr(mac) || is_multicast_ether_addr(mac)) {\n \t\tnetdev_err(netdev, \"%pM not a valid unicast address\\n\", mac);\n \t\treturn -EINVAL;\n \t}\n \n+\tvf = &pf->vf[vf_id];\n+\tret = ice_check_vf_ready_for_cfg(vf);\n+\tif (ret)\n+\t\treturn ret;\n+\n \t/* copy MAC into dflt_lan_addr and trigger a VF reset. The reset\n \t * flow will use the updated dflt_lan_addr and add a MAC filter\n \t * using ice_add_mac. Also set pf_set_mac to indicate that the PF has\n@@ -3314,22 +3333,15 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted)\n {\n \tstruct ice_pf *pf = ice_netdev_to_pf(netdev);\n \tstruct ice_vf *vf;\n+\tint ret;\n \n \tif (ice_validate_vf_id(pf, vf_id))\n \t\treturn -EINVAL;\n \n \tvf = &pf->vf[vf_id];\n-\t/* Don't set Trusted Mode on disabled VF */\n-\tif (ice_is_vf_disabled(vf))\n-\t\treturn -EINVAL;\n-\n-\t/* In case VF is in reset mode, wait until it is completed. Depending\n-\t * on factors like queue disabling routine, this could take ~250ms\n-\t */\n-\tice_wait_on_vf_reset(vf);\n-\n-\tif (ice_check_vf_init(pf, vf))\n-\t\treturn -EBUSY;\n+\tret = ice_check_vf_ready_for_cfg(vf);\n+\tif (ret)\n+\t\treturn ret;\n \n \t/* Check if already trusted */\n \tif (trusted == vf->trusted)\n@@ -3355,13 +3367,15 @@ int ice_set_vf_link_state(struct net_device *netdev, int vf_id, int link_state)\n {\n \tstruct ice_pf *pf = ice_netdev_to_pf(netdev);\n \tstruct ice_vf *vf;\n+\tint ret;\n \n \tif (ice_validate_vf_id(pf, vf_id))\n \t\treturn -EINVAL;\n \n \tvf = &pf->vf[vf_id];\n-\tif (ice_check_vf_init(pf, vf))\n-\t\treturn -EBUSY;\n+\tret = ice_check_vf_ready_for_cfg(vf);\n+\tif (ret)\n+\t\treturn ret;\n \n \tswitch (link_state) {\n \tcase IFLA_VF_LINK_STATE_AUTO:\n@@ -3397,14 +3411,15 @@ int ice_get_vf_stats(struct net_device *netdev, int vf_id,\n \tstruct ice_eth_stats *stats;\n \tstruct ice_vsi *vsi;\n \tstruct ice_vf *vf;\n+\tint ret;\n \n \tif (ice_validate_vf_id(pf, vf_id))\n \t\treturn -EINVAL;\n \n \tvf = &pf->vf[vf_id];\n-\n-\tif (ice_check_vf_init(pf, vf))\n-\t\treturn -EBUSY;\n+\tret = ice_check_vf_ready_for_cfg(vf);\n+\tif (ret)\n+\t\treturn ret;\n \n \tvsi = pf->vsi[vf->lan_vsi_idx];\n \tif (!vsi)\ndiff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h\nindex 4647d636ed36..ac67982751df 100644\n--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h\n+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h\n@@ -38,7 +38,8 @@\n #define ICE_MAX_POLICY_INTR_PER_VF\t33\n #define ICE_MIN_INTR_PER_VF\t\t(ICE_MIN_QS_PER_VF + 1)\n #define ICE_DFLT_INTR_PER_VF\t\t(ICE_DFLT_QS_PER_VF + 1)\n-#define ICE_MAX_VF_RESET_WAIT\t\t15\n+#define ICE_MAX_VF_RESET_TRIES\t\t40\n+#define ICE_MAX_VF_RESET_SLEEP_MS\t20\n \n #define ice_for_each_vf(pf, i) \\\n \tfor ((i) = 0; (i) < (pf)->num_alloc_vfs; (i)++)\n",
    "prefixes": [
        "net-queue",
        "v2"
    ]
}