Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/896861/?format=api
{ "id": 896861, "url": "http://patchwork.ozlabs.org/api/patches/896861/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20180410174959.18757-11-vinicius.gomes@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": "<20180410174959.18757-11-vinicius.gomes@intel.com>", "list_archive_url": null, "date": "2018-04-10T17:49:59", "name": "[next-queue,v7,10/10] igb: Add support for adding offloaded clsflower filters", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "8ab85c07d669cc089445aa316c83055ed7e89762", "submitter": { "id": 72272, "url": "http://patchwork.ozlabs.org/api/people/72272/?format=api", "name": "Vinicius Costa Gomes", "email": "vinicius.gomes@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/20180410174959.18757-11-vinicius.gomes@intel.com/mbox/", "series": [ { "id": 38278, "url": "http://patchwork.ozlabs.org/api/series/38278/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=38278", "date": "2018-04-10T17:49:50", "name": "igb: offloading of receive filters", "version": 7, "mbox": "http://patchwork.ozlabs.org/series/38278/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/896861/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/896861/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<intel-wired-lan-bounces@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" ], "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=osuosl.org\n\t(client-ip=140.211.166.137; helo=fraxinus.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org;\n\tdmarc=none (p=none dis=none) header.from=intel.com" ], "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 40LF7x52VFz9s3C\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 11 Apr 2018 03:50:37 +1000 (AEST)", "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 3DECC8511F;\n\tTue, 10 Apr 2018 17:50:36 +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 tSKeJRHWyJsV; Tue, 10 Apr 2018 17:50:35 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 8F25A85E6B;\n\tTue, 10 Apr 2018 17:50:35 +0000 (UTC)", "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\tby ash.osuosl.org (Postfix) with ESMTP id B63BA1C11AD\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 10 Apr 2018 17:50:30 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id B3ADC85E7C\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 10 Apr 2018 17:50:30 +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 eiXIhBPhLUme for <intel-wired-lan@lists.osuosl.org>;\n\tTue, 10 Apr 2018 17:50:30 +0000 (UTC)", "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n\tby fraxinus.osuosl.org (Postfix) with ESMTPS id 03C908511F\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 10 Apr 2018 17:50:29 +0000 (UTC)", "from orsmga005.jf.intel.com ([10.7.209.41])\n\tby orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t10 Apr 2018 10:50:29 -0700", "from kjnewhou-mobl1.amr.corp.intel.com (HELO localhost.localdomain)\n\t([10.254.183.149])\n\tby orsmga005.jf.intel.com with ESMTP; 10 Apr 2018 10:50:28 -0700" ], "X-Virus-Scanned": [ "amavisd-new at osuosl.org", "amavisd-new at osuosl.org" ], "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6", "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.48,433,1517904000\"; d=\"scan'208\";a=\"215551527\"", "From": "Vinicius Costa Gomes <vinicius.gomes@intel.com>", "To": "intel-wired-lan@lists.osuosl.org", "Date": "Tue, 10 Apr 2018 10:49:59 -0700", "Message-Id": "<20180410174959.18757-11-vinicius.gomes@intel.com>", "X-Mailer": "git-send-email 2.17.0", "In-Reply-To": "<20180410174959.18757-1-vinicius.gomes@intel.com>", "References": "<20180410174959.18757-1-vinicius.gomes@intel.com>", "Subject": "[Intel-wired-lan] [next-queue PATCH v7 10/10] igb: Add support for\n\tadding offloaded clsflower filters", "X-BeenThere": "intel-wired-lan@osuosl.org", "X-Mailman-Version": "2.1.24", "Precedence": "list", "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>", "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>", "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>", "List-Post": "<mailto:intel-wired-lan@osuosl.org>", "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>", "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>", "Cc": "netdev@vger.kernel.org, jesus.sanchez-palencia@intel.com", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "intel-wired-lan-bounces@osuosl.org", "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>" }, "content": "This allows filters added by tc-flower and specifying MAC addresses,\nEthernet types, and the VLAN priority field, to be offloaded to the\ncontroller.\n\nThis reuses most of the infrastructure used by ethtool, but clsflower\nfilters are kept in a separated list, so they are invisible to\nethtool.\n\nTo setup clsflower offloading:\n\n$ tc qdisc replace dev eth0 handle 100: parent root mqprio \\\n \t \t num_tc 3 map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 \\\n\t\t queues 1@0 1@1 2@2 hw 0\n(clsflower offloading depends on the netword driver to be configured\nwith multiple traffic classes, we use mqprio's 'num_tc' parameter to\nset it to 3)\n\n$ tc qdisc add dev eth0 ingress\n\nExamples of filters:\n\n$ tc filter add dev eth0 parent ffff: flower \\\n \t dst_mac aa:aa:aa:aa:aa:aa \\\n\t hw_tc 2 skip_sw\n(just a simple filter filtering for the destination MAC address and\nsteering that traffic to queue 2)\n\n$ tc filter add dev enp2s0 parent ffff: proto 0x22f0 flower \\\n \t src_mac cc:cc:cc:cc:cc:cc \\\n\t hw_tc 1 skip_sw\n(as the i210 doesn't support steering traffic based on the source\naddress alone, we need to use another steering traffic, in this case\nwe are using the ethernet type (0x22f0) to steer traffic to queue 1)\n\nSigned-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>\n---\n drivers/net/ethernet/intel/igb/igb.h | 2 +\n drivers/net/ethernet/intel/igb/igb_main.c | 188 +++++++++++++++++++++-\n 2 files changed, 188 insertions(+), 2 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h\nindex b9b965921e9f..a413284fada6 100644\n--- a/drivers/net/ethernet/intel/igb/igb.h\n+++ b/drivers/net/ethernet/intel/igb/igb.h\n@@ -465,6 +465,7 @@ struct igb_nfc_input {\n struct igb_nfc_filter {\n \tstruct hlist_node nfc_node;\n \tstruct igb_nfc_input filter;\n+\tunsigned long cookie;\n \tu16 etype_reg_index;\n \tu16 sw_idx;\n \tu16 action;\n@@ -604,6 +605,7 @@ struct igb_adapter {\n \n \t/* RX network flow classification support */\n \tstruct hlist_head nfc_filter_list;\n+\tstruct hlist_head cls_flower_list;\n \tunsigned int nfc_filter_count;\n \t/* lock for RX network flow classification filter */\n \tspinlock_t nfc_lock;\ndiff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c\nindex e3f33fb8064e..3c2e68dd0902 100644\n--- a/drivers/net/ethernet/intel/igb/igb_main.c\n+++ b/drivers/net/ethernet/intel/igb/igb_main.c\n@@ -2499,16 +2499,197 @@ static int igb_offload_cbs(struct igb_adapter *adapter,\n \treturn 0;\n }\n \n+#define ETHER_TYPE_FULL_MASK ((__force __be16)~0)\n+#define VLAN_PRIO_FULL_MASK (0x07)\n+\n+static int igb_parse_cls_flower(struct igb_adapter *adapter,\n+\t\t\t\tstruct tc_cls_flower_offload *f,\n+\t\t\t\tint traffic_class,\n+\t\t\t\tstruct igb_nfc_filter *input)\n+{\n+\tstruct netlink_ext_ack *extack = f->common.extack;\n+\n+\tif (f->dissector->used_keys &\n+\t ~(BIT(FLOW_DISSECTOR_KEY_BASIC) |\n+\t BIT(FLOW_DISSECTOR_KEY_CONTROL) |\n+\t BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS) |\n+\t BIT(FLOW_DISSECTOR_KEY_VLAN))) {\n+\t\tNL_SET_ERR_MSG_MOD(extack,\n+\t\t\t\t \"Unsupported key used, only BASIC, CONTROL, ETH_ADDRS and VLAN are supported\");\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\tif (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_ETH_ADDRS)) {\n+\t\tstruct flow_dissector_key_eth_addrs *key, *mask;\n+\n+\t\tkey = skb_flow_dissector_target(f->dissector,\n+\t\t\t\t\t\tFLOW_DISSECTOR_KEY_ETH_ADDRS,\n+\t\t\t\t\t\tf->key);\n+\t\tmask = skb_flow_dissector_target(f->dissector,\n+\t\t\t\t\t\t FLOW_DISSECTOR_KEY_ETH_ADDRS,\n+\t\t\t\t\t\t f->mask);\n+\n+\t\tif (!is_zero_ether_addr(mask->dst)) {\n+\t\t\tif (!is_broadcast_ether_addr(mask->dst)) {\n+\t\t\t\tNL_SET_ERR_MSG_MOD(extack, \"Only full masks are supported for destination MAC address\");\n+\t\t\t\treturn -EINVAL;\n+\t\t\t}\n+\n+\t\t\tinput->filter.match_flags |=\n+\t\t\t\tIGB_FILTER_FLAG_DST_MAC_ADDR;\n+\t\t\tether_addr_copy(input->filter.dst_addr, key->dst);\n+\t\t}\n+\n+\t\tif (!is_zero_ether_addr(mask->src)) {\n+\t\t\tif (!is_broadcast_ether_addr(mask->src)) {\n+\t\t\t\tNL_SET_ERR_MSG_MOD(extack, \"Only full masks are supported for source MAC address\");\n+\t\t\t\treturn -EINVAL;\n+\t\t\t}\n+\n+\t\t\tinput->filter.match_flags |=\n+\t\t\t\tIGB_FILTER_FLAG_SRC_MAC_ADDR;\n+\t\t\tether_addr_copy(input->filter.src_addr, key->src);\n+\t\t}\n+\t}\n+\n+\tif (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_BASIC)) {\n+\t\tstruct flow_dissector_key_basic *key, *mask;\n+\n+\t\tkey = skb_flow_dissector_target(f->dissector,\n+\t\t\t\t\t\tFLOW_DISSECTOR_KEY_BASIC,\n+\t\t\t\t\t\tf->key);\n+\t\tmask = skb_flow_dissector_target(f->dissector,\n+\t\t\t\t\t\t FLOW_DISSECTOR_KEY_BASIC,\n+\t\t\t\t\t\t f->mask);\n+\n+\t\tif (mask->n_proto) {\n+\t\t\tif (mask->n_proto != ETHER_TYPE_FULL_MASK) {\n+\t\t\t\tNL_SET_ERR_MSG_MOD(extack, \"Only full mask is supported for EtherType filter\");\n+\t\t\t\treturn -EINVAL;\n+\t\t\t}\n+\n+\t\t\tinput->filter.match_flags |= IGB_FILTER_FLAG_ETHER_TYPE;\n+\t\t\tinput->filter.etype = key->n_proto;\n+\t\t}\n+\t}\n+\n+\tif (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_VLAN)) {\n+\t\tstruct flow_dissector_key_vlan *key, *mask;\n+\n+\t\tkey = skb_flow_dissector_target(f->dissector,\n+\t\t\t\t\t\tFLOW_DISSECTOR_KEY_VLAN,\n+\t\t\t\t\t\tf->key);\n+\t\tmask = skb_flow_dissector_target(f->dissector,\n+\t\t\t\t\t\t FLOW_DISSECTOR_KEY_VLAN,\n+\t\t\t\t\t\t f->mask);\n+\n+\t\tif (mask->vlan_priority) {\n+\t\t\tif (mask->vlan_priority != VLAN_PRIO_FULL_MASK) {\n+\t\t\t\tNL_SET_ERR_MSG_MOD(extack, \"Only full mask is supported for VLAN priority\");\n+\t\t\t\treturn -EINVAL;\n+\t\t\t}\n+\n+\t\t\tinput->filter.match_flags |= IGB_FILTER_FLAG_VLAN_TCI;\n+\t\t\tinput->filter.vlan_tci = key->vlan_priority;\n+\t\t}\n+\t}\n+\n+\tinput->action = traffic_class;\n+\tinput->cookie = f->cookie;\n+\n+\treturn 0;\n+}\n+\n static int igb_configure_clsflower(struct igb_adapter *adapter,\n \t\t\t\t struct tc_cls_flower_offload *cls_flower)\n {\n-\treturn -EOPNOTSUPP;\n+\tstruct netlink_ext_ack *extack = cls_flower->common.extack;\n+\tstruct igb_nfc_filter *filter, *f;\n+\tint err, tc;\n+\n+\ttc = tc_classid_to_hwtc(adapter->netdev, cls_flower->classid);\n+\tif (tc < 0) {\n+\t\tNL_SET_ERR_MSG_MOD(extack, \"Invalid traffic class\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tfilter = kzalloc(sizeof(*filter), GFP_KERNEL);\n+\tif (!filter)\n+\t\treturn -ENOMEM;\n+\n+\terr = igb_parse_cls_flower(adapter, cls_flower, tc, filter);\n+\tif (err < 0)\n+\t\tgoto err_parse;\n+\n+\tspin_lock(&adapter->nfc_lock);\n+\n+\thlist_for_each_entry(f, &adapter->nfc_filter_list, nfc_node) {\n+\t\tif (!memcmp(&f->filter, &filter->filter, sizeof(f->filter))) {\n+\t\t\terr = -EEXIST;\n+\t\t\tNL_SET_ERR_MSG_MOD(extack,\n+\t\t\t\t\t \"This filter is already set in ethtool\");\n+\t\t\tgoto err_locked;\n+\t\t}\n+\t}\n+\n+\thlist_for_each_entry(f, &adapter->cls_flower_list, nfc_node) {\n+\t\tif (!memcmp(&f->filter, &filter->filter, sizeof(f->filter))) {\n+\t\t\terr = -EEXIST;\n+\t\t\tNL_SET_ERR_MSG_MOD(extack,\n+\t\t\t\t\t \"This filter is already set in cls_flower\");\n+\t\t\tgoto err_locked;\n+\t\t}\n+\t}\n+\n+\terr = igb_add_filter(adapter, filter);\n+\tif (err < 0) {\n+\t\tNL_SET_ERR_MSG_MOD(extack, \"Could not add filter to the adapter\");\n+\t\tgoto err_locked;\n+\t}\n+\n+\thlist_add_head(&filter->nfc_node, &adapter->cls_flower_list);\n+\n+\tspin_unlock(&adapter->nfc_lock);\n+\n+\treturn 0;\n+\n+err_locked:\n+\tspin_unlock(&adapter->nfc_lock);\n+\n+err_parse:\n+\tkfree(filter);\n+\n+\treturn err;\n }\n \n static int igb_delete_clsflower(struct igb_adapter *adapter,\n \t\t\t\tstruct tc_cls_flower_offload *cls_flower)\n {\n-\treturn -EOPNOTSUPP;\n+\tstruct igb_nfc_filter *filter;\n+\tint err;\n+\n+\tspin_lock(&adapter->nfc_lock);\n+\n+\thlist_for_each_entry(filter, &adapter->cls_flower_list, nfc_node)\n+\t\tif (filter->cookie == cls_flower->cookie)\n+\t\t\tbreak;\n+\n+\tif (!filter) {\n+\t\terr = -ENOENT;\n+\t\tgoto out;\n+\t}\n+\n+\terr = igb_erase_filter(adapter, filter);\n+\tif (err < 0)\n+\t\tgoto out;\n+\n+\thlist_del(&filter->nfc_node);\n+\tkfree(filter);\n+\n+out:\n+\tspin_unlock(&adapter->nfc_lock);\n+\n+\treturn err;\n }\n \n static int igb_setup_tc_cls_flower(struct igb_adapter *adapter,\n@@ -9353,6 +9534,9 @@ static void igb_nfc_filter_exit(struct igb_adapter *adapter)\n \thlist_for_each_entry(rule, &adapter->nfc_filter_list, nfc_node)\n \t\tigb_erase_filter(adapter, rule);\n \n+\thlist_for_each_entry(rule, &adapter->cls_flower_list, nfc_node)\n+\t\tigb_erase_filter(adapter, rule);\n+\n \tspin_unlock(&adapter->nfc_lock);\n }\n \n", "prefixes": [ "next-queue", "v7", "10/10" ] }