get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 724792,
    "url": "http://patchwork.ozlabs.org/api/patches/724792/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20170206223852.31177-3-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-3-jacob.e.keller@intel.com>",
    "list_archive_url": null,
    "date": "2017-02-06T22:38:45",
    "name": "[PART2,2/9] i40e: check current configured input set when adding ntuple filters",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "28a19ba64adc459e70d9ddf24defdaef4233f207",
    "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-3-jacob.e.keller@intel.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/724792/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/724792/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 3vHMpq0h71z9s1y\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue,  7 Feb 2017 09:39:31 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 9674B30A4B;\n\tMon,  6 Feb 2017 22:39:29 +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 qCE5lT5M4qs9; Mon,  6 Feb 2017 22:39:23 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id BF45F30A9B;\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 788AC1C22BA\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tMon,  6 Feb 2017 22:39:00 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 782FD815B4\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tMon,  6 Feb 2017 22:39:00 +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 ABe2xm3yZNti 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 03A7C81CA2\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tMon,  6 Feb 2017 22:38:54 +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=\"61907685\"",
        "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:45 -0800",
        "Message-Id": "<20170206223852.31177-3-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 2/9] 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\nThe use of ntohl and ntohs is not strictly necessary for correctness,\nbut it helps avoid a sparse warning due to the construction of\n\"!~<be16>\" degrades the be16 value into an integer when doing negation.\nThis could alternatively be fixed by the following code construction\nwithout the byteswaps,\n\n  if (!<value>)\n    <disable field>\n  else if (~<value>)\n    <return error>\n  else\n    <enable field>\n\nHowever, this construction is confusing because the error return occurs\nin the middle, which is misleading to other readers. Additionally, it\nmakes the condition for the <enable field> much more difficult to\nprocess due to it being in an else statement.\n\nSigned-off-by: Jacob Keller <jacob.e.keller@intel.com>\nChange-Id: 3d8db46cb28ea0afdaac8c5b31a2bfb90e3a4102\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 9957eca8f71d..c32658ca5c22 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e.h\n@@ -742,6 +742,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 772dd234d581..5a7718e67c0a 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c\n@@ -2346,6 +2346,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@@ -2371,11 +2373,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@@ -2687,36 +2720,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)\n+\t\t\tnew_mask &= ~I40E_L3_SRC_MASK;\n+\t\telse if (!~ntohl(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)\n+\t\t\tnew_mask &= ~I40E_L3_DST_MASK;\n+\t\telse if (!~ntohl(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 || ~tcp_ip4_spec->psrc)\n+\t\tif (!tcp_ip4_spec->psrc)\n+\t\t\tnew_mask &= ~I40E_L4_SRC_MASK;\n+\t\telse if (!~ntohs(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 || ~tcp_ip4_spec->pdst)\n+\t\tif (!tcp_ip4_spec->pdst)\n+\t\t\tnew_mask &= ~I40E_L4_DST_MASK;\n+\t\telse if (!~ntohs(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@@ -2728,15 +2799,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)\n+\t\t\tnew_mask &= ~I40E_L3_SRC_MASK;\n+\t\telse if (!~ntohl(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)\n+\t\t\tnew_mask &= ~I40E_L3_DST_MASK;\n+\t\telse if (!~ntohl(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)\n+\t\t\tnew_mask &= ~(I40E_L4_SRC_MASK | I40E_L4_DST_MASK);\n+\t\telse if (!~ntohl(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@@ -2750,11 +2833,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@@ -2798,7 +2885,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": [
        "PART2",
        "2/9"
    ]
}