Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/736394/?format=api
{ "id": 736394, "url": "http://patchwork.ozlabs.org/api/patches/736394/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20170307230523.28702-2-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": "<20170307230523.28702-2-jacob.e.keller@intel.com>", "list_archive_url": null, "date": "2017-03-07T23:05:23", "name": "[v2,2/2] i40e: check current configured input set when adding ntuple filters", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "8a901638ec9899ff7f88715be28cfdab3a9b5f59", "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/20170307230523.28702-2-jacob.e.keller@intel.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/736394/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/736394/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 fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\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 3vdC376n20z9sN6\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 8 Mar 2017 10:06:59 +1100 (AEDT)", "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 3A6B38855C;\n\tTue, 7 Mar 2017 23:06:58 +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 IRJK327ypatE; Tue, 7 Mar 2017 23:06:56 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 186738855B;\n\tTue, 7 Mar 2017 23:06:56 +0000 (UTC)", "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\tby ash.osuosl.org (Postfix) with ESMTP id 63CE21C05CE\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 7 Mar 2017 23:06:54 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 5A7EF884DF\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 7 Mar 2017 23:06:54 +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 iUNKqnj-G2vn for <intel-wired-lan@lists.osuosl.org>;\n\tTue, 7 Mar 2017 23:06:53 +0000 (UTC)", "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby fraxinus.osuosl.org (Postfix) with ESMTPS id 74D6488462\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 7 Mar 2017 23:06:53 +0000 (UTC)", "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t07 Mar 2017 15:06:46 -0800", "from jekeller-desk.amr.corp.intel.com (HELO\n\tjekeller-jetplane.jekeller.internal) ([10.166.35.174])\n\tby fmsmga002.fm.intel.com with ESMTP; 07 Mar 2017 15:06:46 -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,260,1486454400\"; d=\"scan'208\";\n\ta=\"1139243735\"", "From": "Jacob Keller <jacob.e.keller@intel.com>", "To": "Intel Wired LAN <intel-wired-lan@lists.osuosl.org>", "Date": "Tue, 7 Mar 2017 15:05:23 -0800", "Message-Id": "<20170307230523.28702-2-jacob.e.keller@intel.com>", "X-Mailer": "git-send-email 2.9.3", "In-Reply-To": "<20170307230523.28702-1-jacob.e.keller@intel.com>", "References": "<20170307230523.28702-1-jacob.e.keller@intel.com>", "Subject": "[Intel-wired-lan] [PATCH v2 2/2] i40e: check current configured\n\tinput set when adding ntuple 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": "Do not assume that hardware has been programmed with the default mask,\nbut instead read the input set registers to determine what is currently\nprogrammed. This ensures that all programmed filters match exactly how\nthe hardware will interpret them, avoiding confusion regarding filter\nbehavior.\n\nThis sets the initial ground-work for allowing custom input sets where\nsome fields are disabled. A future patch will fully implement this\nfeature.\n\nInstead of using bitwise negation, we'll just explicitly check for the\ncorrect value. The use of htonl and htons are used to silence sparse\nwarnings. The compiler should be able to handle the constant value and\navoid actually performing a byteswap>\n\nSigned-off-by: Jacob Keller <jacob.e.keller@intel.com>\nChange-Id: 3d8db46cb28ea0afdaac8c5b31a2bfb90e3a4102\n---\nThis is a new version of \"[PART2,2/9] i40e: check current configured\ninput set when adding ntuple filters\"\n\n drivers/net/ethernet/intel/i40e/i40e.h | 19 ++++\n drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 117 +++++++++++++++++++++----\n 2 files changed, 121 insertions(+), 15 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h\nindex e8173b6be368..0933c494d524 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e.h\n@@ -746,6 +746,25 @@ static inline int i40e_get_fd_cnt_all(struct i40e_pf *pf)\n \treturn pf->hw.fdir_shared_filter_count + pf->fdir_pf_filter_count;\n }\n \n+/**\n+ * i40e_read_fd_input_set - reads value of flow director input set register\n+ * @pf: pointer to the PF struct\n+ * @addr: register addr\n+ *\n+ * This function reads value of flow director input set register\n+ * specified by 'addr' (which is specific to flow-type)\n+ **/\n+static inline u64 i40e_read_fd_input_set(struct i40e_pf *pf, u16 addr)\n+{\n+\tu64 val;\n+\n+\tval = i40e_read_rx_ctl(&pf->hw, I40E_PRTQF_FD_INSET(addr, 1));\n+\tval <<= 32;\n+\tval += i40e_read_rx_ctl(&pf->hw, I40E_PRTQF_FD_INSET(addr, 0));\n+\n+\treturn val;\n+}\n+\n /* needed by i40e_ethtool.c */\n int i40e_up(struct i40e_vsi *vsi);\n void i40e_down(struct i40e_vsi *vsi);\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c\nindex 3c006bbf5ff7..79d83fe1ce97 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c\n@@ -2388,6 +2388,8 @@ static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,\n \t\t\t(struct ethtool_rx_flow_spec *)&cmd->fs;\n \tstruct i40e_fdir_filter *rule = NULL;\n \tstruct hlist_node *node2;\n+\tu64 input_set;\n+\tu16 index;\n \n \thlist_for_each_entry_safe(rule, node2,\n \t\t\t\t &pf->fdir_filter_list, fdir_node) {\n@@ -2413,11 +2415,42 @@ static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,\n \tfsp->h_u.tcp_ip4_spec.ip4src = rule->dst_ip;\n \tfsp->h_u.tcp_ip4_spec.ip4dst = rule->src_ip;\n \n-\t/* Set the mask fields */\n-\tfsp->m_u.tcp_ip4_spec.psrc = htons(0xFFFF);\n-\tfsp->m_u.tcp_ip4_spec.pdst = htons(0xFFFF);\n-\tfsp->m_u.tcp_ip4_spec.ip4src = htonl(0xFFFFFFFF);\n-\tfsp->m_u.tcp_ip4_spec.ip4dst = htonl(0xFFFFFFFF);\n+\tswitch (rule->flow_type) {\n+\tcase TCP_V4_FLOW:\n+\t\tindex = I40E_FILTER_PCTYPE_NONF_IPV4_TCP;\n+\t\tbreak;\n+\tcase UDP_V4_FLOW:\n+\t\tindex = I40E_FILTER_PCTYPE_NONF_IPV4_UDP;\n+\t\tbreak;\n+\tcase IP_USER_FLOW:\n+\t\tindex = I40E_FILTER_PCTYPE_NONF_IPV4_OTHER;\n+\t\tbreak;\n+\tdefault:\n+\t\t/* If we have stored a filter with a flow type not listed here\n+\t\t * it is almost certainly a driver bug. WARN(), and then\n+\t\t * assign the input_set as if all fields are enabled to avoid\n+\t\t * reading unassigned memory.\n+\t\t */\n+\t\tWARN(1, \"Missing input set index for flow_type %d\\n\",\n+\t\t rule->flow_type);\n+\t\tinput_set = 0xFFFFFFFFFFFFFFFFULL;\n+\t\tgoto no_input_set;\n+\t}\n+\n+\tinput_set = i40e_read_fd_input_set(pf, index);\n+\n+no_input_set:\n+\tif (input_set & I40E_L3_SRC_MASK)\n+\t\tfsp->m_u.tcp_ip4_spec.ip4src = htonl(0xFFFF);\n+\n+\tif (input_set & I40E_L3_DST_MASK)\n+\t\tfsp->m_u.tcp_ip4_spec.ip4dst = htonl(0xFFFF);\n+\n+\tif (input_set & I40E_L4_SRC_MASK)\n+\t\tfsp->m_u.tcp_ip4_spec.psrc = htons(0xFFFFFFFF);\n+\n+\tif (input_set & I40E_L4_DST_MASK)\n+\t\tfsp->m_u.tcp_ip4_spec.pdst = htons(0xFFFFFFFF);\n \n \tif (rule->dest_ctl == I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET)\n \t\tfsp->ring_cookie = RX_CLS_FLOW_DISC;\n@@ -2729,36 +2762,74 @@ static int i40e_del_fdir_entry(struct i40e_vsi *vsi,\n \n /**\n * i40e_check_fdir_input_set - Check that a given rx_flow_spec mask is valid\n+ * @vsi: pointer to the targeted VSI\n * @fsp: pointer to Rx flow specification\n *\n * Ensures that a given ethtool_rx_flow_spec has a valid mask.\n **/\n-static int i40e_check_fdir_input_set(struct ethtool_rx_flow_spec *fsp)\n+static int i40e_check_fdir_input_set(struct i40e_vsi *vsi,\n+\t\t\t\t struct ethtool_rx_flow_spec *fsp)\n {\n+\tstruct i40e_pf *pf = vsi->back;\n \tstruct ethtool_tcpip4_spec *tcp_ip4_spec;\n \tstruct ethtool_usrip4_spec *usr_ip4_spec;\n+\tu64 current_mask, new_mask;\n+\tu16 index;\n+\n+\tswitch (fsp->flow_type & ~FLOW_EXT) {\n+\tcase TCP_V4_FLOW:\n+\t\tindex = I40E_FILTER_PCTYPE_NONF_IPV4_TCP;\n+\t\tbreak;\n+\tcase UDP_V4_FLOW:\n+\t\tindex = I40E_FILTER_PCTYPE_NONF_IPV4_UDP;\n+\t\tbreak;\n+\tcase IP_USER_FLOW:\n+\t\tindex = I40E_FILTER_PCTYPE_NONF_IPV4_OTHER;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\t/* Read the current input set from register memory. */\n+\tcurrent_mask = i40e_read_fd_input_set(pf, index);\n+\tnew_mask = current_mask;\n \n \t/* Verify the provided mask is valid. */\n \tswitch (fsp->flow_type & ~FLOW_EXT) {\n-\tcase SCTP_V4_FLOW:\n \tcase TCP_V4_FLOW:\n \tcase UDP_V4_FLOW:\n \t\ttcp_ip4_spec = &fsp->m_u.tcp_ip4_spec;\n \n \t\t/* IPv4 source address */\n-\t\tif (!tcp_ip4_spec->ip4src || ~tcp_ip4_spec->ip4src)\n+\t\tif (tcp_ip4_spec->ip4src == htonl(0xFFFFFFFF))\n+\t\t\tnew_mask |= I40E_L3_SRC_MASK;\n+\t\telse if (!tcp_ip4_spec->ip4src)\n+\t\t\tnew_mask &= ~I40E_L3_SRC_MASK;\n+\t\telse\n \t\t\treturn -EOPNOTSUPP;\n \n \t\t/* IPv4 destination address */\n-\t\tif (!tcp_ip4_spec->ip4dst || ~tcp_ip4_spec->ip4dst)\n+\t\tif (tcp_ip4_spec->ip4dst == htonl(0xFFFFFFFF))\n+\t\t\tnew_mask |= I40E_L3_DST_MASK;\n+\t\telse if (!tcp_ip4_spec->ip4dst)\n+\t\t\tnew_mask &= ~I40E_L3_DST_MASK;\n+\t\telse\n \t\t\treturn -EOPNOTSUPP;\n \n \t\t/* L4 source port */\n-\t\tif (!tcp_ip4_spec->psrc || (__be16)~tcp_ip4_spec->psrc)\n+\t\tif (tcp_ip4_spec->psrc == htons(0xFFFF))\n+\t\t\tnew_mask |= I40E_L4_SRC_MASK;\n+\t\telse if (!tcp_ip4_spec->psrc)\n+\t\t\tnew_mask &= ~I40E_L4_SRC_MASK;\n+\t\telse\n \t\t\treturn -EOPNOTSUPP;\n \n \t\t/* L4 destination port */\n-\t\tif (!tcp_ip4_spec->pdst || (__be16)~tcp_ip4_spec->pdst)\n+\t\tif (tcp_ip4_spec->pdst == htons(0xFFFF))\n+\t\t\tnew_mask |= I40E_L4_DST_MASK;\n+\t\telse if (!tcp_ip4_spec->pdst)\n+\t\t\tnew_mask &= ~I40E_L4_DST_MASK;\n+\t\telse\n \t\t\treturn -EOPNOTSUPP;\n \n \t\t/* Filtering on Type of Service is not supported. */\n@@ -2770,15 +2841,27 @@ static int i40e_check_fdir_input_set(struct ethtool_rx_flow_spec *fsp)\n \t\tusr_ip4_spec = &fsp->m_u.usr_ip4_spec;\n \n \t\t/* IPv4 source address */\n-\t\tif (!usr_ip4_spec->ip4src || ~usr_ip4_spec->ip4src)\n+\t\tif (usr_ip4_spec->ip4src == htonl(0xFFFFFFFF))\n+\t\t\tnew_mask |= I40E_L3_SRC_MASK;\n+\t\telse if (!usr_ip4_spec->ip4src)\n+\t\t\tnew_mask &= ~I40E_L3_SRC_MASK;\n+\t\telse\n \t\t\treturn -EOPNOTSUPP;\n \n \t\t/* IPv4 destination address */\n-\t\tif (!usr_ip4_spec->ip4dst || ~usr_ip4_spec->ip4dst)\n+\t\tif (usr_ip4_spec->ip4dst == htonl(0xFFFFFFFF))\n+\t\t\tnew_mask |= I40E_L3_DST_MASK;\n+\t\telse if (!usr_ip4_spec->ip4dst)\n+\t\t\tnew_mask &= ~I40E_L3_DST_MASK;\n+\t\telse\n \t\t\treturn -EOPNOTSUPP;\n \n \t\t/* First 4 bytes of L4 header */\n-\t\tif (!usr_ip4_spec->l4_4_bytes || ~usr_ip4_spec->l4_4_bytes)\n+\t\tif (usr_ip4_spec->l4_4_bytes == htonl(0xFFFFFFFF))\n+\t\t\tnew_mask |= I40E_L4_SRC_MASK | I40E_L4_DST_MASK;\n+\t\telse if (!usr_ip4_spec->l4_4_bytes)\n+\t\t\tnew_mask &= ~(I40E_L4_SRC_MASK | I40E_L4_DST_MASK);\n+\t\telse\n \t\t\treturn -EOPNOTSUPP;\n \n \t\t/* Filtering on Type of Service is not supported. */\n@@ -2792,11 +2875,15 @@ static int i40e_check_fdir_input_set(struct ethtool_rx_flow_spec *fsp)\n \t\t/* L4 protocol doesn't have a mask field. */\n \t\tif (usr_ip4_spec->proto)\n \t\t\treturn -EINVAL;\n+\n \t\tbreak;\n \tdefault:\n \t\treturn -EOPNOTSUPP;\n \t}\n \n+\tif (new_mask != current_mask)\n+\t\treturn -EOPNOTSUPP;\n+\n \treturn 0;\n }\n \n@@ -2840,7 +2927,7 @@ static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,\n \tif (fsp->flow_type & FLOW_MAC_EXT)\n \t\treturn -EINVAL;\n \n-\tret = i40e_check_fdir_input_set(fsp);\n+\tret = i40e_check_fdir_input_set(vsi, fsp);\n \tif (ret)\n \t\treturn ret;\n \n", "prefixes": [ "v2", "2/2" ] }