get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 693941,
    "url": "http://patchwork.ozlabs.org/api/patches/693941/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1478896779-13697-8-git-send-email-bimmy.pujari@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": "<1478896779-13697-8-git-send-email-bimmy.pujari@intel.com>",
    "list_archive_url": null,
    "date": "2016-11-11T20:39:31",
    "name": "[next,S54,07/15] i40e: move all updates for VLAN mode into i40e_sync_vsi_filters",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "1f0625fb7a835b57117472a7528285cc68e84e7b",
    "submitter": {
        "id": 68919,
        "url": "http://patchwork.ozlabs.org/api/people/68919/?format=api",
        "name": "Pujari, Bimmy",
        "email": "bimmy.pujari@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/1478896779-13697-8-git-send-email-bimmy.pujari@intel.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/693941/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/693941/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<intel-wired-lan-bounces@lists.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"
        ],
        "Received": [
            "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3tFsJh6tm7z9t2g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 12 Nov 2016 07:41:24 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 63C2A9611D;\n\tFri, 11 Nov 2016 20:41:23 +0000 (UTC)",
            "from hemlock.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 1fiLUZwqpEow; Fri, 11 Nov 2016 20:41:20 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 7362C96129;\n\tFri, 11 Nov 2016 20:41:17 +0000 (UTC)",
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\tby ash.osuosl.org (Postfix) with ESMTP id 478EC1CEC94\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 11 Nov 2016 20:41:15 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 42544C2242\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 11 Nov 2016 20:41:15 +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 t7VzevqK2YOF for <intel-wired-lan@lists.osuosl.org>;\n\tFri, 11 Nov 2016 20:41:14 +0000 (UTC)",
            "from mga06.intel.com (mga06.intel.com [134.134.136.31])\n\tby fraxinus.osuosl.org (Postfix) with ESMTPS id E31F1C29C9\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 11 Nov 2016 20:41:13 +0000 (UTC)",
            "from fmsmga005.fm.intel.com ([10.253.24.32])\n\tby orsmga104.jf.intel.com with ESMTP; 11 Nov 2016 12:41:13 -0800",
            "from bimmy.jf.intel.com (HELO bimmy.linux1.jf.intel.com)\n\t([134.134.2.167])\n\tby fmsmga005.fm.intel.com with ESMTP; 11 Nov 2016 12:41:13 -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-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.31,474,1473145200\"; d=\"scan'208\";a=\"30297950\"",
        "From": "Bimmy Pujari <bimmy.pujari@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org",
        "Date": "Fri, 11 Nov 2016 12:39:31 -0800",
        "Message-Id": "<1478896779-13697-8-git-send-email-bimmy.pujari@intel.com>",
        "X-Mailer": "git-send-email 2.4.11",
        "In-Reply-To": "<1478896779-13697-1-git-send-email-bimmy.pujari@intel.com>",
        "References": "<1478896779-13697-1-git-send-email-bimmy.pujari@intel.com>",
        "Subject": "[Intel-wired-lan] [next PATCH S54 07/15] i40e: move all updates for\n\tVLAN mode into i40e_sync_vsi_filters",
        "X-BeenThere": "intel-wired-lan@lists.osuosl.org",
        "X-Mailman-Version": "2.1.18-1",
        "Precedence": "list",
        "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.lists.osuosl.org>",
        "List-Unsubscribe": "<http://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>",
        "List-Post": "<mailto:intel-wired-lan@lists.osuosl.org>",
        "List-Help": "<mailto:intel-wired-lan-request@lists.osuosl.org?subject=help>",
        "List-Subscribe": "<http://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=subscribe>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "intel-wired-lan-bounces@lists.osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@lists.osuosl.org>"
    },
    "content": "From: Jacob Keller <jacob.e.keller@intel.com>\n\nIn a similar fashion to how we handled exiting VLAN mode, move the logic\nin i40e_vsi_add_vlan into i40e_sync_vsi_filters. Extract this logic into\nits own function for ease of understanding as it will become quite\ncomplex.\n\nThe new function, i40e_correct_mac_vlan_filters() correctly updates all\nfilters for when we need to enter VLAN mode, exit VLAN mode, and also\nenforces the PVID when assigned.\n\nCall i40e_correct_mac_vlan_filters from i40e_sync_vsi_filters passing it\nthe number of active VLAN filters, and the two temporary lists.\n\nRemove the function for updating VLAN=0 filters from i40e_vsi_add_vlan.\n\nThe end result is that the logic for entering and exiting VLAN mode is\nin one location which has the most knowledge about all filters. This\nensures that we always correctly have the non-VLAN filters assigned to\nVID=0 or VID=-1 regardless of how we ended up getting to this result.\n\nAdditionally this enforces the PVID at sync time so that we know for\ncertain that an assigned PVID results in only filters with that PVID\nwill be added to the firmware.\n\nSigned-off-by: Jacob Keller <jacob.e.keller@intel.com>\nChange-ID: I895cee81e9c92d0a16baee38bd0ca51bbb14e372\n---\n drivers/net/ethernet/intel/i40e/i40e_main.c | 214 +++++++++++++++-------------\n 1 file changed, 113 insertions(+), 101 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c\nindex c99e54f..e8cb82b 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_main.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c\n@@ -1226,6 +1226,107 @@ bool i40e_is_vsi_in_vlan(struct i40e_vsi *vsi)\n }\n \n /**\n+ * i40e_correct_mac_vlan_filters - Correct non-VLAN filters if necessary\n+ * @vsi: the vsi to configure\n+ * @tmp_add_list: list of filters ready to be added\n+ * @tmp_del_list: list of filters ready to be deleted\n+ * @vlan_filters: the number of active VLAN filters\n+ *\n+ * Update VLAN=0 and VLAN=-1 (I40E_VLAN_ANY) filters properly so that they\n+ * behave as expected. If we have any active VLAN filters remaining or about\n+ * to be added then we need to update non-VLAN filters to be marked as VLAN=0\n+ * so that they only match against untagged traffic. If we no longer have any\n+ * active VLAN filters, we need to make all non-VLAN filters marked as VLAN=-1\n+ * so that they match against both tagged and untagged traffic. In this way,\n+ * we ensure that we correctly receive the desired traffic. This ensures that\n+ * when we have an active VLAN we will receive only untagged traffic and\n+ * traffic matching active VLANs. If we have no active VLANs then we will\n+ * operate in non-VLAN mode and receive all traffic, tagged or untagged.\n+ *\n+ * Finally, in a similar fashion, this function also corrects filters when\n+ * there is an active PVID assigned to this VSI.\n+ *\n+ * In case of memory allocation failure return -ENOMEM. Otherwise, return 0.\n+ *\n+ * This function is only expected to be called from within\n+ * i40e_sync_vsi_filters.\n+ *\n+ * NOTE: This function expects to be called while under the\n+ * mac_filter_hash_lock\n+ */\n+static int i40e_correct_mac_vlan_filters(struct i40e_vsi *vsi,\n+\t\t\t\t\t struct hlist_head *tmp_add_list,\n+\t\t\t\t\t struct hlist_head *tmp_del_list,\n+\t\t\t\t\t int vlan_filters)\n+{\n+\tstruct i40e_mac_filter *f, *add_head;\n+\tstruct hlist_node *h;\n+\tint bkt, new_vlan;\n+\n+\t/* To determine if a particular filter needs to be replaced we\n+\t * have the three following conditions:\n+\t *\n+\t * a) if we have a PVID assigned, then all filters which are\n+\t *    not marked as VLAN=PVID must be replaced with filters that\n+\t *    are.\n+\t * b) otherwise, if we have any active VLANS, all filters\n+\t *    which are marked as VLAN=-1 must be replaced with\n+\t *    filters marked as VLAN=0\n+\t * c) finally, if we do not have any active VLANS, all filters\n+\t *    which are marked as VLAN=0 must be replaced with filters\n+\t *    marked as VLAN=-1\n+\t */\n+\n+\t/* Update the filters about to be added in place */\n+\thlist_for_each_entry(f, tmp_add_list, hlist) {\n+\t\tif (vsi->info.pvid && f->vlan != vsi->info.pvid)\n+\t\t\tf->vlan = vsi->info.pvid;\n+\t\telse if (vlan_filters && f->vlan == I40E_VLAN_ANY)\n+\t\t\tf->vlan = 0;\n+\t\telse if (!vlan_filters && f->vlan == 0)\n+\t\t\tf->vlan = I40E_VLAN_ANY;\n+\t}\n+\n+\t/* Update the remaining active filters */\n+\thash_for_each_safe(vsi->mac_filter_hash, bkt, h, f, hlist) {\n+\t\t/* Combine the checks for whether a filter needs to be changed\n+\t\t * and then determine the new vlan inside the if block, in\n+\t\t * order to avoid duplicating code for adding the new filter\n+\t\t * then deleting the old filter.\n+\t\t */\n+\t\tif ((vsi->info.pvid && f->vlan != vsi->info.pvid) ||\n+\t\t    (vlan_filters && f->vlan == I40E_VLAN_ANY) ||\n+\t\t    (!vlan_filters && f->vlan == 0)) {\n+\t\t\t/* Determine the new vlan we will be adding */\n+\t\t\tif (vsi->info.pvid)\n+\t\t\t\tnew_vlan = vsi->info.pvid;\n+\t\t\telse if (vlan_filters)\n+\t\t\t\tnew_vlan = 0;\n+\t\t\telse\n+\t\t\t\tnew_vlan = I40E_VLAN_ANY;\n+\n+\t\t\t/* Create the new filter */\n+\t\t\tadd_head = i40e_add_filter(vsi, f->macaddr, new_vlan);\n+\t\t\tif (!add_head)\n+\t\t\t\treturn -ENOMEM;\n+\n+\t\t\t/* Put the replacement filter into the add list */\n+\t\t\thash_del(&add_head->hlist);\n+\t\t\thlist_add_head(&add_head->hlist, tmp_add_list);\n+\n+\t\t\t/* Put the original filter into the delete list */\n+\t\t\tf->state = I40E_FILTER_REMOVE;\n+\t\t\thash_del(&f->hlist);\n+\t\t\thlist_add_head(&f->hlist, tmp_del_list);\n+\t\t}\n+\t}\n+\n+\tvsi->has_vlan_filter = !!vlan_filters;\n+\n+\treturn 0;\n+}\n+\n+/**\n  * i40e_rm_default_mac_filter - Remove the default MAC filter set by NVM\n  * @vsi: the PF Main VSI - inappropriate for any other VSI\n  * @macaddr: the MAC address\n@@ -1915,8 +2016,6 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)\n \tstruct hlist_head tmp_add_list, tmp_del_list;\n \tstruct i40e_mac_filter *f, *add_head = NULL;\n \tstruct i40e_hw *hw = &vsi->back->hw;\n-\tunsigned int vlan_any_filters = 0;\n-\tunsigned int non_vlan_filters = 0;\n \tunsigned int failed_filters = 0;\n \tunsigned int vlan_filters = 0;\n \tbool promisc_changed = false;\n@@ -1973,66 +2072,21 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)\n \t\t\t\thlist_add_head(&f->hlist, &tmp_add_list);\n \t\t\t}\n \n-\t\t\t/* Count the number of each type of filter we have\n-\t\t\t * remaining, ignoring any filters we're about to\n-\t\t\t * delete.\n+\t\t\t/* Count the number of active (current and new) VLAN\n+\t\t\t * filters we have now. Does not count filters which\n+\t\t\t * are marked for deletion.\n \t\t\t */\n \t\t\tif (f->vlan > 0)\n \t\t\t\tvlan_filters++;\n-\t\t\telse if (!f->vlan)\n-\t\t\t\tnon_vlan_filters++;\n-\t\t\telse\n-\t\t\t\tvlan_any_filters++;\n \t\t}\n \n-\t\t/* We should never have VLAN=-1 filters at the same time as we\n-\t\t * have either VLAN=0 or VLAN>0 filters, so warn about this\n-\t\t * case here to help catch any issues.\n-\t\t */\n-\t\tWARN_ON(vlan_any_filters && (vlan_filters + non_vlan_filters));\n-\n-\t\t/* If we only have VLAN=0 filters remaining, and don't have\n-\t\t * any other VLAN filters, we need to convert these VLAN=0\n-\t\t * filters into VLAN=-1 (I40E_VLAN_ANY) so that we operate\n-\t\t * correctly in non-VLAN mode and receive all traffic tagged\n-\t\t * or untagged.\n-\t\t */\n-\t\tif (non_vlan_filters && !vlan_filters) {\n-\t\t\thash_for_each_safe(vsi->mac_filter_hash, bkt, h, f,\n-\t\t\t\t\t   hlist) {\n-\t\t\t\t/* Only replace VLAN=0 filters */\n-\t\t\t\tif (f->vlan)\n-\t\t\t\t\tcontinue;\n-\n-\t\t\t\t/* Allocate a replacement element */\n-\t\t\t\tadd_head = kzalloc(sizeof(*add_head),\n-\t\t\t\t\t\t   GFP_KERNEL);\n-\t\t\t\tif (!add_head)\n-\t\t\t\t\tgoto err_no_memory_locked;\n+\t\tretval = i40e_correct_mac_vlan_filters(vsi,\n+\t\t\t\t\t\t       &tmp_add_list,\n+\t\t\t\t\t\t       &tmp_del_list,\n+\t\t\t\t\t\t       vlan_filters);\n+\t\tif (retval)\n+\t\t\tgoto err_no_memory_locked;\n \n-\t\t\t\t/* Copy the filter, with new state and VLAN */\n-\t\t\t\t*add_head = *f;\n-\t\t\t\tadd_head->state = I40E_FILTER_NEW;\n-\t\t\t\tadd_head->vlan = I40E_VLAN_ANY;\n-\n-\t\t\t\t/* Move the replacement to the add list */\n-\t\t\t\tINIT_HLIST_NODE(&add_head->hlist);\n-\t\t\t\thlist_add_head(&add_head->hlist,\n-\t\t\t\t\t       &tmp_add_list);\n-\n-\t\t\t\t/* Move the original to the delete list */\n-\t\t\t\tf->state = I40E_FILTER_REMOVE;\n-\t\t\t\thash_del(&f->hlist);\n-\t\t\t\thlist_add_head(&f->hlist, &tmp_del_list);\n-\t\t\t}\n-\n-\t\t\t/* Also update any filters on the tmp_add list */\n-\t\t\thlist_for_each_entry(f, &tmp_add_list, hlist) {\n-\t\t\t\tif (!f->vlan)\n-\t\t\t\t\tf->vlan = I40E_VLAN_ANY;\n-\t\t\t}\n-\t\t\tadd_head = NULL;\n-\t\t}\n \t\tspin_unlock_bh(&vsi->mac_filter_hash_lock);\n \t}\n \n@@ -2097,14 +2151,6 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)\n \t\tdel_list = NULL;\n \t}\n \n-\t/* After finishing notifying firmware of the deleted filters, update\n-\t * the cached value of vsi->has_vlan_filter. Note that we are safe to\n-\t * use just !!vlan_filters here because if we only have VLAN=0 (that\n-\t * is, non_vlan_filters) these will all be converted to VLAN=-1 in the\n-\t * logic above already so this value would still be correct.\n-\t */\n-\tvsi->has_vlan_filter = !!vlan_filters;\n-\n \tif (!hlist_empty(&tmp_add_list)) {\n \t\t/* Do all the adds now. */\n \t\tfilter_list_len = hw->aq.asq_buf_size /\n@@ -2520,48 +2566,14 @@ int i40e_add_vlan_all_mac(struct i40e_vsi *vsi, s16 vid)\n  **/\n int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid)\n {\n-\tstruct i40e_mac_filter *f, *add_f, *del_f;\n-\tstruct hlist_node *h;\n-\tint bkt, err;\n+\tint err;\n \n \t/* Locked once because all functions invoked below iterates list*/\n \tspin_lock_bh(&vsi->mac_filter_hash_lock);\n-\n \terr = i40e_add_vlan_all_mac(vsi, vid);\n-\tif (err) {\n-\t\tspin_unlock_bh(&vsi->mac_filter_hash_lock);\n-\t\treturn err;\n-\t}\n-\n-\t/* When we add a new VLAN filter, we need to make sure that all existing\n-\t * filters which are marked as vid=-1 (I40E_VLAN_ANY) are converted to\n-\t * vid=0. The simplest way is just search for all filters marked as\n-\t * vid=-1 and replace them with vid=0. This converts all filters that\n-\t * were marked to receive all traffic (tagged or untagged) into\n-\t * filters to receive only untagged traffic, so that we don't receive\n-\t * tagged traffic for VLANs which we have not configured.\n-\t */\n-\tif (vid > 0 && !vsi->info.pvid) {\n-\t\thash_for_each_safe(vsi->mac_filter_hash, bkt, h, f, hlist) {\n-\t\t\tif (f->state == I40E_FILTER_REMOVE)\n-\t\t\t\tcontinue;\n-\t\t\tdel_f = i40e_find_filter(vsi, f->macaddr,\n-\t\t\t\t\t\t I40E_VLAN_ANY);\n-\t\t\tif (!del_f)\n-\t\t\t\tcontinue;\n-\t\t\tadd_f = i40e_add_filter(vsi, f->macaddr, 0);\n-\t\t\tif (!add_f) {\n-\t\t\t\tdev_info(&vsi->back->pdev->dev,\n-\t\t\t\t\t \"Could not add filter 0 for %pM\\n\",\n-\t\t\t\t\tf->macaddr);\n-\t\t\t\tspin_unlock_bh(&vsi->mac_filter_hash_lock);\n-\t\t\t\treturn -ENOMEM;\n-\t\t\t}\n-\t\t\t__i40e_del_filter(vsi, del_f);\n-\t\t}\n-\t}\n-\n \tspin_unlock_bh(&vsi->mac_filter_hash_lock);\n+\tif (err)\n+\t\treturn err;\n \n \t/* schedule our worker thread which will take care of\n \t * applying the new filter changes\n",
    "prefixes": [
        "next",
        "S54",
        "07/15"
    ]
}