Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/737550/?format=api
{ "id": 737550, "url": "http://patchwork.ozlabs.org/api/patches/737550/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1489177325-13156-3-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": "<1489177325-13156-3-git-send-email-bimmy.pujari@intel.com>", "list_archive_url": null, "date": "2017-03-10T20:22:01", "name": "[next,S62,2/6] i40e: Clean up handling of private flags", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "7b9dab3385b8ff342425c869c86779d337d52232", "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/1489177325-13156-3-git-send-email-bimmy.pujari@intel.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/737550/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/737550/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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\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 3vfxyz0DG3z9s7x\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 11 Mar 2017 06:24:26 +1100 (AEDT)", "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 86FFD89CEA;\n\tFri, 10 Mar 2017 19:24:25 +0000 (UTC)", "from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id JTwH89VoP4kq; Fri, 10 Mar 2017 19:24:23 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 5784289DA3;\n\tFri, 10 Mar 2017 19:24:23 +0000 (UTC)", "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\tby ash.osuosl.org (Postfix) with ESMTP id 3349F1C0169\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 10 Mar 2017 19:24:18 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 2ED7489E03\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 10 Mar 2017 19:24:18 +0000 (UTC)", "from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id feZsH6zK6N9N for <intel-wired-lan@lists.osuosl.org>;\n\tFri, 10 Mar 2017 19:24:14 +0000 (UTC)", "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby whitealder.osuosl.org (Postfix) with ESMTPS id 1ACE689CA3\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 10 Mar 2017 19:24:14 +0000 (UTC)", "from orsmga001.jf.intel.com ([10.7.209.18])\n\tby orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t10 Mar 2017 11:24:12 -0800", "from bimmy.jf.intel.com (HELO bimmy.linux1.jf.intel.com)\n\t([10.166.35.87])\n\tby orsmga001.jf.intel.com with ESMTP; 10 Mar 2017 11:24:12 -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.36,142,1486454400\"; d=\"scan'208\";\n\ta=\"1107116168\"", "From": "Bimmy Pujari <bimmy.pujari@intel.com>", "To": "intel-wired-lan@lists.osuosl.org", "Date": "Fri, 10 Mar 2017 12:22:01 -0800", "Message-Id": "<1489177325-13156-3-git-send-email-bimmy.pujari@intel.com>", "X-Mailer": "git-send-email 2.4.11", "In-Reply-To": "<1489177325-13156-1-git-send-email-bimmy.pujari@intel.com>", "References": "<1489177325-13156-1-git-send-email-bimmy.pujari@intel.com>", "Subject": "[Intel-wired-lan] [next PATCH S62 2/6] i40e: Clean up handling of\n\tprivate flags", "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: Alexander Duyck <alexander.h.duyck@intel.com>\n\nThis patch cleans up and addresses several issues in the way that i40e\nhandles private flags. Previously the code was choosing fixed bits and\ntrying to match them up with strings in a somewhat haphazard way. This\nresulted in the possibility for adding a new bit and causing a mismatch as\nthe private flags are linear bits starting at 0, and the private flags in\nthe driver were split up over a group specific to the PF and a group that\nwas global.\n\nWhat this change does is define an array of structs used to represent the\nprivate flags. Contained within the structs are the bits necessary to know\nwhich flags to set and/or clear depending on the state of the bit. By\ndoing this we can add new bits in the future with minimal overhead and\navoid creating possible mis-matches should we need to remove a flag based\non compile options.\n\nSigned-off-by: Alexander Duyck <alexander.h.duyck@intel.com>\nChange-ID: Ia3214ab04f0ab2f70354ac0997a135f1d01b0acd\n---\n drivers/net/ethernet/intel/i40e/i40e.h | 8 --\n drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 189 +++++++++++++++----------\n 2 files changed, 112 insertions(+), 85 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h\nindex be69d7e..e324b6f 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e.h\n@@ -91,14 +91,6 @@\n #define I40E_QUEUE_WAIT_RETRY_LIMIT\t10\n #define I40E_INT_NAME_STR_LEN\t\t(IFNAMSIZ + 16)\n \n-/* Ethtool Private Flags */\n-#define I40E_PRIV_FLAGS_MFP_FLAG\t\tBIT(0)\n-#define I40E_PRIV_FLAGS_LINKPOLL_FLAG\t\tBIT(1)\n-#define I40E_PRIV_FLAGS_FD_ATR\t\t\tBIT(2)\n-#define I40E_PRIV_FLAGS_VEB_STATS\t\tBIT(3)\n-#define I40E_PRIV_FLAGS_HW_ATR_EVICT\t\tBIT(4)\n-#define I40E_PRIV_FLAGS_TRUE_PROMISC_SUPPORT\tBIT(5)\n-\n #define I40E_NVM_VERSION_LO_SHIFT\t0\n #define I40E_NVM_VERSION_LO_MASK\t(0xff << I40E_NVM_VERSION_LO_SHIFT)\n #define I40E_NVM_VERSION_HI_SHIFT\t12\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c\nindex 03ffd08..56dccf8 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c\n@@ -207,22 +207,36 @@ static const char i40e_gstrings_test[][ETH_GSTRING_LEN] = {\n \n #define I40E_TEST_LEN (sizeof(i40e_gstrings_test) / ETH_GSTRING_LEN)\n \n-static const char i40e_priv_flags_strings[][ETH_GSTRING_LEN] = {\n-\t\"MFP\",\n-\t\"LinkPolling\",\n-\t\"flow-director-atr\",\n-\t\"veb-stats\",\n-\t\"hw-atr-eviction\",\n+struct i40e_priv_flags {\n+\tchar flag_string[ETH_GSTRING_LEN];\n+\tu64 flag;\n+\tbool read_only;\n };\n \n-#define I40E_PRIV_FLAGS_STR_LEN ARRAY_SIZE(i40e_priv_flags_strings)\n+#define I40E_PRIV_FLAG(_name, _flag, _read_only) { \\\n+\t.flag_string = _name, \\\n+\t.flag = _flag, \\\n+\t.read_only = _read_only, \\\n+}\n+\n+static const struct i40e_priv_flags i40e_gstrings_priv_flags[] = {\n+\t/* NOTE: MFP setting cannot be changed */\n+\tI40E_PRIV_FLAG(\"MFP\", I40E_FLAG_MFP_ENABLED, 1),\n+\tI40E_PRIV_FLAG(\"LinkPolling\", I40E_FLAG_LINK_POLLING_ENABLED, 0),\n+\tI40E_PRIV_FLAG(\"flow-director-atr\", I40E_FLAG_FD_ATR_ENABLED, 0),\n+\tI40E_PRIV_FLAG(\"veb-stats\", I40E_FLAG_VEB_STATS_ENABLED, 0),\n+\tI40E_PRIV_FLAG(\"hw-atr-eviction\", I40E_FLAG_HW_ATR_EVICT_CAPABLE, 0),\n+};\n+\n+#define I40E_PRIV_FLAGS_STR_LEN ARRAY_SIZE(i40e_gstrings_priv_flags)\n \n /* Private flags with a global effect, restricted to PF 0 */\n-static const char i40e_gl_priv_flags_strings[][ETH_GSTRING_LEN] = {\n-\t\"vf-true-promisc-support\",\n+static const struct i40e_priv_flags i40e_gl_gstrings_priv_flags[] = {\n+\tI40E_PRIV_FLAG(\"vf-true-promisc-support\",\n+\t\t I40E_FLAG_TRUE_PROMISC_SUPPORT, 0),\n };\n \n-#define I40E_GL_PRIV_FLAGS_STR_LEN ARRAY_SIZE(i40e_gl_priv_flags_strings)\n+#define I40E_GL_PRIV_FLAGS_STR_LEN ARRAY_SIZE(i40e_gl_gstrings_priv_flags)\n \n /**\n * i40e_partition_setting_complaint - generic complaint for MFP restriction\n@@ -1660,12 +1674,18 @@ static void i40e_get_strings(struct net_device *netdev, u32 stringset,\n \t\t/* BUG_ON(p - data != I40E_STATS_LEN * ETH_GSTRING_LEN); */\n \t\tbreak;\n \tcase ETH_SS_PRIV_FLAGS:\n-\t\tmemcpy(data, i40e_priv_flags_strings,\n-\t\t I40E_PRIV_FLAGS_STR_LEN * ETH_GSTRING_LEN);\n-\t\tdata += I40E_PRIV_FLAGS_STR_LEN * ETH_GSTRING_LEN;\n-\t\tif (pf->hw.pf_id == 0)\n-\t\t\tmemcpy(data, i40e_gl_priv_flags_strings,\n-\t\t\t I40E_GL_PRIV_FLAGS_STR_LEN * ETH_GSTRING_LEN);\n+\t\tfor (i = 0; i < I40E_PRIV_FLAGS_STR_LEN; i++) {\n+\t\t\tsnprintf(p, ETH_GSTRING_LEN, \"%s\",\n+\t\t\t\t i40e_gstrings_priv_flags[i].flag_string);\n+\t\t\tp += ETH_GSTRING_LEN;\n+\t\t}\n+\t\tif (pf->hw.pf_id != 0)\n+\t\t\tbreak;\n+\t\tfor (i = 0; i < I40E_GL_PRIV_FLAGS_STR_LEN; i++) {\n+\t\t\tsnprintf(p, ETH_GSTRING_LEN, \"%s\",\n+\t\t\t\t i40e_gl_gstrings_priv_flags[i].flag_string);\n+\t\t\tp += ETH_GSTRING_LEN;\n+\t\t}\n \t\tbreak;\n \tdefault:\n \t\tbreak;\n@@ -3945,7 +3965,7 @@ static int i40e_set_rxfh(struct net_device *netdev, const u32 *indir,\n * @dev: network interface device structure\n *\n * The get string set count and the string set should be matched for each\n- * flag returned. Add new strings for each flag to the i40e_priv_flags_strings\n+ * flag returned. Add new strings for each flag to the i40e_gstrings_priv_flags\n * array.\n *\n * Returns a u32 bitmap of flags.\n@@ -3955,19 +3975,27 @@ static u32 i40e_get_priv_flags(struct net_device *dev)\n \tstruct i40e_netdev_priv *np = netdev_priv(dev);\n \tstruct i40e_vsi *vsi = np->vsi;\n \tstruct i40e_pf *pf = vsi->back;\n-\tu32 ret_flags = 0;\n-\n-\tret_flags |= pf->flags & I40E_FLAG_LINK_POLLING_ENABLED ?\n-\t\tI40E_PRIV_FLAGS_LINKPOLL_FLAG : 0;\n-\tret_flags |= pf->flags & I40E_FLAG_FD_ATR_ENABLED ?\n-\t\tI40E_PRIV_FLAGS_FD_ATR : 0;\n-\tret_flags |= pf->flags & I40E_FLAG_VEB_STATS_ENABLED ?\n-\t\tI40E_PRIV_FLAGS_VEB_STATS : 0;\n-\tret_flags |= pf->hw_disabled_flags & I40E_FLAG_HW_ATR_EVICT_CAPABLE ?\n-\t\t0 : I40E_PRIV_FLAGS_HW_ATR_EVICT;\n-\tif (pf->hw.pf_id == 0) {\n-\t\tret_flags |= pf->flags & I40E_FLAG_TRUE_PROMISC_SUPPORT ?\n-\t\t\tI40E_PRIV_FLAGS_TRUE_PROMISC_SUPPORT : 0;\n+\tu32 i, j, ret_flags = 0;\n+\n+\tfor (i = 0; i < I40E_PRIV_FLAGS_STR_LEN; i++) {\n+\t\tconst struct i40e_priv_flags *priv_flags;\n+\n+\t\tpriv_flags = &i40e_gstrings_priv_flags[i];\n+\n+\t\tif (priv_flags->flag & pf->flags)\n+\t\t\tret_flags |= BIT(i);\n+\t}\n+\n+\tif (pf->hw.pf_id != 0)\n+\t\treturn ret_flags;\n+\n+\tfor (j = 0; j < I40E_GL_PRIV_FLAGS_STR_LEN; j++) {\n+\t\tconst struct i40e_priv_flags *priv_flags;\n+\n+\t\tpriv_flags = &i40e_gl_gstrings_priv_flags[j];\n+\n+\t\tif (priv_flags->flag & pf->flags)\n+\t\t\tret_flags |= BIT(i + j);\n \t}\n \n \treturn ret_flags;\n@@ -3983,54 +4011,65 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)\n \tstruct i40e_netdev_priv *np = netdev_priv(dev);\n \tstruct i40e_vsi *vsi = np->vsi;\n \tstruct i40e_pf *pf = vsi->back;\n-\tu16 sw_flags = 0, valid_flags = 0;\n-\tbool reset_required = false;\n-\tbool promisc_change = false;\n-\tint ret;\n+\tu64 changed_flags;\n+\tu32 i, j;\n \n-\t/* NOTE: MFP is not settable */\n+\tchanged_flags = pf->flags;\n \n-\tif (flags & I40E_PRIV_FLAGS_LINKPOLL_FLAG)\n-\t\tpf->flags |= I40E_FLAG_LINK_POLLING_ENABLED;\n-\telse\n-\t\tpf->flags &= ~I40E_FLAG_LINK_POLLING_ENABLED;\n+\tfor (i = 0; i < I40E_PRIV_FLAGS_STR_LEN; i++) {\n+\t\tconst struct i40e_priv_flags *priv_flags;\n \n-\t/* allow the user to control the state of the Flow\n-\t * Director ATR (Application Targeted Routing) feature\n-\t * of the driver\n-\t */\n-\tif (flags & I40E_PRIV_FLAGS_FD_ATR) {\n-\t\tpf->flags |= I40E_FLAG_FD_ATR_ENABLED;\n-\t} else {\n-\t\tpf->flags &= ~I40E_FLAG_FD_ATR_ENABLED;\n-\t\tpf->hw_disabled_flags |= I40E_FLAG_FD_ATR_ENABLED;\n+\t\tpriv_flags = &i40e_gstrings_priv_flags[i];\n \n-\t\t/* flush current ATR settings */\n-\t\tset_bit(__I40E_FD_FLUSH_REQUESTED, &pf->state);\n+\t\tif (priv_flags->read_only)\n+\t\t\tcontinue;\n+\n+\t\tif (flags & BIT(i))\n+\t\t\tpf->flags |= priv_flags->flag;\n+\t\telse\n+\t\t\tpf->flags &= ~(priv_flags->flag);\n \t}\n \n-\tif ((flags & I40E_PRIV_FLAGS_VEB_STATS) &&\n-\t !(pf->flags & I40E_FLAG_VEB_STATS_ENABLED)) {\n-\t\tpf->flags |= I40E_FLAG_VEB_STATS_ENABLED;\n-\t\treset_required = true;\n-\t} else if (!(flags & I40E_PRIV_FLAGS_VEB_STATS) &&\n-\t\t (pf->flags & I40E_FLAG_VEB_STATS_ENABLED)) {\n-\t\tpf->flags &= ~I40E_FLAG_VEB_STATS_ENABLED;\n-\t\treset_required = true;\n+\tif (pf->hw.pf_id != 0)\n+\t\tgoto flags_complete;\n+\n+\tfor (j = 0; j < I40E_GL_PRIV_FLAGS_STR_LEN; j++) {\n+\t\tconst struct i40e_priv_flags *priv_flags;\n+\n+\t\tpriv_flags = &i40e_gl_gstrings_priv_flags[j];\n+\n+\t\tif (priv_flags->read_only)\n+\t\t\tcontinue;\n+\n+\t\tif (flags & BIT(i + j))\n+\t\t\tpf->flags |= priv_flags->flag;\n+\t\telse\n+\t\t\tpf->flags &= ~(priv_flags->flag);\n \t}\n \n-\tif (pf->hw.pf_id == 0) {\n-\t\tif ((flags & I40E_PRIV_FLAGS_TRUE_PROMISC_SUPPORT) &&\n-\t\t !(pf->flags & I40E_FLAG_TRUE_PROMISC_SUPPORT)) {\n-\t\t\tpf->flags |= I40E_FLAG_TRUE_PROMISC_SUPPORT;\n-\t\t\tpromisc_change = true;\n-\t\t} else if (!(flags & I40E_PRIV_FLAGS_TRUE_PROMISC_SUPPORT) &&\n-\t\t\t (pf->flags & I40E_FLAG_TRUE_PROMISC_SUPPORT)) {\n-\t\t\tpf->flags &= ~I40E_FLAG_TRUE_PROMISC_SUPPORT;\n-\t\t\tpromisc_change = true;\n-\t\t}\n+flags_complete:\n+\tchanged_flags ^= pf->flags;\n+\n+\t/* Process any additional changes needed as a result of flag changes.\n+\t * The changed_flags value reflects the list of bits that were\n+\t * changed in the code above.\n+\t */\n+\n+\t/* Flush current ATR settings if ATR was disabled */\n+\tif ((changed_flags & I40E_FLAG_FD_ATR_ENABLED) &&\n+\t !(pf->flags & I40E_FLAG_FD_ATR_ENABLED)) {\n+\t\tpf->hw_disabled_flags |= I40E_FLAG_FD_ATR_ENABLED;\n+\t\tset_bit(__I40E_FD_FLUSH_REQUESTED, &pf->state);\n \t}\n-\tif (promisc_change) {\n+\n+\t/* Only allow ATR evict on hardware that is capable of handling it */\n+\tif (pf->hw_disabled_flags & I40E_FLAG_HW_ATR_EVICT_CAPABLE)\n+\t\tpf->flags &= ~I40E_FLAG_HW_ATR_EVICT_CAPABLE;\n+\n+\tif (changed_flags & I40E_FLAG_TRUE_PROMISC_SUPPORT) {\n+\t\tu16 sw_flags = 0, valid_flags = 0;\n+\t\tint ret;\n+\n \t\tif (!(pf->flags & I40E_FLAG_TRUE_PROMISC_SUPPORT))\n \t\t\tsw_flags = I40E_AQ_SET_SWITCH_CFG_PROMISC;\n \t\tvalid_flags = I40E_AQ_SET_SWITCH_CFG_PROMISC;\n@@ -4046,14 +4085,10 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags)\n \t\t}\n \t}\n \n-\tif ((flags & I40E_PRIV_FLAGS_HW_ATR_EVICT) &&\n-\t (pf->flags & I40E_FLAG_HW_ATR_EVICT_CAPABLE))\n-\t\tpf->hw_disabled_flags &= ~I40E_FLAG_HW_ATR_EVICT_CAPABLE;\n-\telse\n-\t\tpf->hw_disabled_flags |= I40E_FLAG_HW_ATR_EVICT_CAPABLE;\n-\n-\t/* if needed, issue reset to cause things to take effect */\n-\tif (reset_required)\n+\t/* Issue reset to cause things to take effect, as additional bits\n+\t * are added we will need to create a mask of bits requiring reset\n+\t */\n+\tif (changed_flags & I40E_FLAG_VEB_STATS_ENABLED)\n \t\ti40e_do_reset(pf, BIT(__I40E_PF_RESET_REQUESTED));\n \n \treturn 0;\n", "prefixes": [ "next", "S62", "2/6" ] }