Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/724789/?format=api
{ "id": 724789, "url": "http://patchwork.ozlabs.org/api/patches/724789/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20170206223852.31177-7-jacob.e.keller@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": "<20170206223852.31177-7-jacob.e.keller@intel.com>", "list_archive_url": null, "date": "2017-02-06T22:38:49", "name": "[PART2,6/9] i40e: add parsing of flexible filter fields from userdef", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "ab98f222531b2eef89c9f58b6d1c73090f59b052", "submitter": { "id": 9784, "url": "http://patchwork.ozlabs.org/api/people/9784/?format=api", "name": "Jacob Keller", "email": "jacob.e.keller@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/20170206223852.31177-7-jacob.e.keller@intel.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/724789/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/724789/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 silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\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 3vHMpj0rwxz9s1y\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 7 Feb 2017 09:39:25 +1100 (AEDT)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 9551430339;\n\tMon, 6 Feb 2017 22:39:23 +0000 (UTC)", "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id D4qiahX7vGZa; Mon, 6 Feb 2017 22:39:20 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 35AF530A95;\n\tMon, 6 Feb 2017 22:39:03 +0000 (UTC)", "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\tby ash.osuosl.org (Postfix) with ESMTP id 070421BFF07\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tMon, 6 Feb 2017 22:38:59 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 05E67815B4\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tMon, 6 Feb 2017 22:38:59 +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 1vdA2HI+PXEO for <intel-wired-lan@lists.osuosl.org>;\n\tMon, 6 Feb 2017 22:38:55 +0000 (UTC)", "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby whitealder.osuosl.org (Postfix) with ESMTPS id 9DA0C88819\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tMon, 6 Feb 2017 22:38:55 +0000 (UTC)", "from fmsmga005.fm.intel.com ([10.253.24.32])\n\tby fmsmga102.fm.intel.com with ESMTP; 06 Feb 2017 14:38:54 -0800", "from jekeller-desk.amr.corp.intel.com (HELO\n\tjekeller-desk.jekeller.internal) ([10.166.35.174])\n\tby fmsmga005.fm.intel.com with ESMTP; 06 Feb 2017 14:38:54 -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.33,342,1477983600\"; d=\"scan'208\";a=\"61907697\"", "From": "Jacob Keller <jacob.e.keller@intel.com>", "To": "Intel Wired LAN <intel-wired-lan@lists.osuosl.org>", "Date": "Mon, 6 Feb 2017 14:38:49 -0800", "Message-Id": "<20170206223852.31177-7-jacob.e.keller@intel.com>", "X-Mailer": "git-send-email 2.12.0.rc0.151.g8a5726c42288", "In-Reply-To": "<20170206223852.31177-1-jacob.e.keller@intel.com>", "References": "<20170206223852.31177-1-jacob.e.keller@intel.com>", "Subject": "[Intel-wired-lan] [PART2 PATCH 6/9] i40e: add parsing of flexible\n\tfilter fields from userdef", "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": "Add code to parse the user-def field into a data structure format. This\ncode is intended to allow future extensions of the user-def field by\nkeeping all code that actually reads and writes the field into a single\nlocation. This ensures that we do not litter the driver with references\nto the user-def field and minimizes the amount of bitwise operations we\nneed to do on the data.\n\nAdd code which parses the lower 32bits into a flexible word and its\noffset. This will be used in a future patch to enable flexible filters\nwhich can match on some arbitrary data in the packet payload. For now,\nwe just return -EOPNOTSUPP when this is used.\n\nAdd code to fill in the user-def field when reporting the filter back,\neven though we don't actually implement any user-def fields yet.\n\nAdditionally, ensure that we mask the extended FLOW_EXT bit from the\nflow_type now that we will be accepting filters which have the FLOW_EXT\nbit set (and thus make use of the user-def field).\n\nSigned-off-by: Jacob Keller <jacob.e.keller@intel.com>\nChange-Id: 238845035c179380a347baa8db8223304f5f6dd7\n---\n drivers/net/ethernet/intel/i40e/i40e.h | 9 +++\n drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 108 ++++++++++++++++++++++++-\n 2 files changed, 116 insertions(+), 1 deletion(-)", "diff": "diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h\nindex 4d54d5005ad3..bffcfc1041e7 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e.h\n@@ -206,6 +206,15 @@ enum i40e_fd_stat_idx {\n #define I40E_FD_ATR_TUNNEL_STAT_IDX(pf_id) \\\n \t\t\t(I40E_FD_STAT_PF_IDX(pf_id) + I40E_FD_STAT_ATR_TUNNEL)\n \n+/* The following structure contains the data parsed from the user-defined\n+ * field of the ethtool_rx_flow_spec structure.\n+ */\n+struct i40e_rx_flow_userdef {\n+\tbool flex_filter;\n+\tu16 flex_word;\n+\tu16 flex_offset;\n+};\n+\n struct i40e_fdir_filter {\n \tstruct hlist_node fdir_node;\n \t/* filter ipnut set */\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c\nindex f6cca3254fd4..56adffa049d6 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c\n@@ -2293,6 +2293,100 @@ static int i40e_get_rss_hash_opts(struct i40e_pf *pf, struct ethtool_rxnfc *cmd)\n \treturn 0;\n }\n \n+/* i40e_check_mask - Check whether a mask field is set\n+ * @mask: the full mask value\n+ * @field; mask of the field to check\n+ *\n+ * If the given mask is fully set, return positive value. If the mask for the\n+ * field is fully unset, return zero. Otherwise return a negative error code.\n+ */\n+static int i40e_check_mask(u64 mask, u64 field)\n+{\n+\tu64 value = mask & field;\n+\n+\tif (value == field)\n+\t\treturn 1;\n+\telse if (!value)\n+\t\treturn 0;\n+\telse\n+\t\treturn -1;\n+}\n+\n+/* i40e_parse_rx_flow_user_data - Deconstruct user-defined data\n+ * @fsp: pointer to rx flow specification\n+ * @data: pointer to userdef data structure for storage\n+ *\n+ * Read the user-defined data and deconstruct the value into a structure. No\n+ * other code should read the user-defined data, so as to ensure that every\n+ * place consistently reads the value correctly.\n+ *\n+ * The user-defined field is a 64bit Big Endian format value, which we\n+ * deconstruct by reading bits or bit fields from it. Single bit flags shall\n+ * be defined starting from the highest bits, while small bit field values\n+ * shall be defined starting from the lowest bits.\n+ *\n+ * Returns 0 if the data is valid, and non-zero if the userdef data is invalid\n+ * and the filter should be rejected. The data structure will always be\n+ * modified even if FLOW_EXT is not set.\n+\n+ *\n+ */\n+static int i40e_parse_rx_flow_user_data(struct ethtool_rx_flow_spec *fsp,\n+\t\t\t\t\tstruct i40e_rx_flow_userdef *data)\n+{\n+\tu64 value, mask;\n+\tint valid;\n+\n+\t/* Zero memory first so it's always consistent. */\n+\tmemset(data, 0, sizeof(*data));\n+\n+\tif (!(fsp->flow_type & FLOW_EXT))\n+\t\treturn 0;\n+\n+\tvalue = be64_to_cpu(*((__be64 *)fsp->h_ext.data));\n+\tmask = be64_to_cpu(*((__be64 *)fsp->m_ext.data));\n+\n+#define I40E_USERDEF_FLEX_WORD\t\tGENMASK_ULL(15, 0)\n+#define I40E_USERDEF_FLEX_OFFSET\tGENMASK_ULL(31, 16)\n+#define I40E_USERDEF_FLEX_FILTER\tGENMASK_ULL(31, 0)\n+\n+\tvalid = i40e_check_mask(mask, I40E_USERDEF_FLEX_FILTER);\n+\tif (valid < 0) {\n+\t\treturn -EINVAL;\n+\t} else if (valid) {\n+\t\tdata->flex_word = value & I40E_USERDEF_FLEX_WORD;\n+\t\tdata->flex_offset =\n+\t\t\t(value & I40E_USERDEF_FLEX_OFFSET) >> 16;\n+\t\tdata->flex_filter = true;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/* i40e_fill_rx_flow_user_data - Fill in user-defined data field\n+ * @fsp: pointer to rx_flow specification\n+ *\n+ * Reads the userdef data structure and properly fills in the user defined\n+ * fields of the rx_flow_spec.\n+ */\n+static void i40e_fill_rx_flow_user_data(struct ethtool_rx_flow_spec *fsp,\n+\t\t\t\t\tstruct i40e_rx_flow_userdef *data)\n+{\n+\tu64 value = 0, mask = 0;\n+\n+\tif (data->flex_filter) {\n+\t\tvalue |= data->flex_word;\n+\t\tvalue |= (u64)data->flex_offset << 16;\n+\t\tmask |= I40E_USERDEF_FLEX_FILTER;\n+\t}\n+\n+\tif (value || mask)\n+\t\tfsp->flow_type |= FLOW_EXT;\n+\n+\t*((__be64 *)fsp->h_ext.data) = cpu_to_be64(value);\n+\t*((__be64 *)fsp->m_ext.data) = cpu_to_be64(mask);\n+}\n+\n /**\n * i40e_get_ethtool_fdir_all - Populates the rule count of a command\n * @pf: Pointer to the physical function struct\n@@ -2344,6 +2438,7 @@ static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,\n {\n \tstruct ethtool_rx_flow_spec *fsp =\n \t\t\t(struct ethtool_rx_flow_spec *)&cmd->fs;\n+\tstruct i40e_rx_flow_userdef userdef = {0};\n \tstruct i40e_fdir_filter *rule = NULL;\n \tstruct hlist_node *node2;\n \tu64 input_set;\n@@ -2430,6 +2525,8 @@ static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,\n \t\t}\n \t}\n \n+\ti40e_fill_rx_flow_user_data(fsp, &userdef);\n+\n \treturn 0;\n }\n \n@@ -3003,6 +3100,7 @@ static int i40e_check_fdir_input_set(struct i40e_vsi *vsi,\n static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,\n \t\t\t\t struct ethtool_rxnfc *cmd)\n {\n+\tstruct i40e_rx_flow_userdef userdef;\n \tstruct ethtool_rx_flow_spec *fsp;\n \tstruct i40e_fdir_filter *input;\n \tu16 dest_vsi = 0, q_index = 0;\n@@ -3029,6 +3127,14 @@ static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,\n \n \tfsp = (struct ethtool_rx_flow_spec *)&cmd->fs;\n \n+\t/* Parse the user-defined field */\n+\tif (i40e_parse_rx_flow_user_data(fsp, &userdef))\n+\t\treturn -EINVAL;\n+\n+\t/* Flexible filters not yet supported */\n+\tif (userdef.flex_filter)\n+\t\treturn -EOPNOTSUPP;\n+\n \t/* Extended MAC field is not supported */\n \tif (fsp->flow_type & FLOW_MAC_EXT)\n \t\treturn -EINVAL;\n@@ -3082,7 +3188,7 @@ static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,\n \tinput->cnt_index = I40E_FD_SB_STAT_IDX(pf->hw.pf_id);\n \tinput->dst_ip = fsp->h_u.tcp_ip4_spec.ip4src;\n \tinput->src_ip = fsp->h_u.tcp_ip4_spec.ip4dst;\n-\tinput->flow_type = fsp->flow_type;\n+\tinput->flow_type = fsp->flow_type & ~FLOW_EXT;\n \tinput->ip4_proto = fsp->h_u.usr_ip4_spec.proto;\n \n \t/* Reverse the src and dest notion, since the HW expects them to be from\n", "prefixes": [ "PART2", "6/9" ] }