get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 806683,
    "url": "http://patchwork.ozlabs.org/api/patches/806683/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/1503942035-24924-10-git-send-email-michael.chan@broadcom.com/",
    "project": {
        "id": 7,
        "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api",
        "name": "Linux network development",
        "link_name": "netdev",
        "list_id": "netdev.vger.kernel.org",
        "list_email": "netdev@vger.kernel.org",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<1503942035-24924-10-git-send-email-michael.chan@broadcom.com>",
    "list_archive_url": null,
    "date": "2017-08-28T17:40:33",
    "name": "[net-next,09/11] bnxt_en: bnxt: add TC flower filter offload support",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "288ea57aed4766cd021b9005245eac924049145f",
    "submitter": {
        "id": 68365,
        "url": "http://patchwork.ozlabs.org/api/people/68365/?format=api",
        "name": "Michael Chan",
        "email": "michael.chan@broadcom.com"
    },
    "delegate": {
        "id": 34,
        "url": "http://patchwork.ozlabs.org/api/users/34/?format=api",
        "username": "davem",
        "first_name": "David",
        "last_name": "Miller",
        "email": "davem@davemloft.net"
    },
    "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/1503942035-24924-10-git-send-email-michael.chan@broadcom.com/mbox/",
    "series": [
        {
            "id": 225,
            "url": "http://patchwork.ozlabs.org/api/series/225/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=225",
            "date": "2017-08-28T17:40:24",
            "name": "bnxt_en: Updates.",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/225/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/806683/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/806683/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<netdev-owner@vger.kernel.org>",
        "X-Original-To": "patchwork-incoming@ozlabs.org",
        "Delivered-To": "patchwork-incoming@ozlabs.org",
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=broadcom.com header.i=@broadcom.com\n\theader.b=\"Ly5qgrbc\"; dkim-atps=neutral"
        ],
        "Received": [
            "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xgzb55qZYz9sP5\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 29 Aug 2017 03:41:21 +1000 (AEST)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751752AbdH1RlP (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 28 Aug 2017 13:41:15 -0400",
            "from mail-qt0-f178.google.com ([209.85.216.178]:36310 \"EHLO\n\tmail-qt0-f178.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751304AbdH1RlC (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 28 Aug 2017 13:41:02 -0400",
            "by mail-qt0-f178.google.com with SMTP id v29so5266989qtv.3\n\tfor <netdev@vger.kernel.org>; Mon, 28 Aug 2017 10:41:01 -0700 (PDT)",
            "from localhost.dhcp.broadcom.net ([192.19.255.250])\n\tby smtp.gmail.com with ESMTPSA id\n\t20sm592006qtu.52.2017.08.28.10.40.58\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tMon, 28 Aug 2017 10:41:00 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=broadcom.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=obvaLzWxzZS7Wli0AzEdAceTI4rRcPaagQNE/hbfqwU=;\n\tb=Ly5qgrbcd8SDSsSNK2Cc7mB0+osqZOfA6zFBrBqo/jedqDQdNL0TPLlqOTNN6XGUSC\n\tZIeDsnGlb2obANla0xJ/MJ408ctwyRvODkkz7QJqxF43mjh5i7Vql8aesEFBTlzLpgkZ\n\t8jIRzpwIHZyMpUykFkleeQBYN/gNorzXrr9pw=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=obvaLzWxzZS7Wli0AzEdAceTI4rRcPaagQNE/hbfqwU=;\n\tb=RrV4V0W68wJ6qVNqOsKMeWTCqlv8rmDSOTRsrCz6DOWPfpMVz3oj+UWe3ZmD7rJdmG\n\tbOo1uQCBQA09vUgYw/FX3t8ZgKK82F7vjnfFar2sYZj8YN+zPIk7YR2zK89/XUvWZ9O8\n\tAT3goqEwFLn5Q2kYERhrCYu+S5KveX0gGKGx9CQWev4sDc6R6KfXzT2b2olDQq0zCins\n\tRf5NlgIs2UxEr+MAGKTCbH7Y8dutUntlMjJHQ+QVALeaGh5/ZOGSGBtaUGqVXMMQi8nu\n\t2/jKEPiI5KYKun3ORAAYb0Htn6oJroA0jk+TAe7d75ZqVMEmRdSteFrZU7uGQFQ7Re6N\n\tKdiw==",
        "X-Gm-Message-State": "AHYfb5hOZjWB6uH54j6QWSC2Xg5tdLbY8yCtauoJ6/Utej4KuMMzs1xO\n\tIy5aqYiwQ/1TAR/5rjw=",
        "X-Received": "by 10.200.57.125 with SMTP id t58mr1823934qtb.227.1503942060945; \n\tMon, 28 Aug 2017 10:41:00 -0700 (PDT)",
        "From": "Michael Chan <michael.chan@broadcom.com>",
        "To": "davem@davemloft.net",
        "Cc": "netdev@vger.kernel.org, Sathya Perla <sathya.perla@broadcom.com>",
        "Subject": "[PATCH net-next 09/11] bnxt_en: bnxt: add TC flower filter offload\n\tsupport",
        "Date": "Mon, 28 Aug 2017 13:40:33 -0400",
        "Message-Id": "<1503942035-24924-10-git-send-email-michael.chan@broadcom.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1503942035-24924-1-git-send-email-michael.chan@broadcom.com>",
        "References": "<1503942035-24924-1-git-send-email-michael.chan@broadcom.com>",
        "Sender": "netdev-owner@vger.kernel.org",
        "Precedence": "bulk",
        "List-ID": "<netdev.vger.kernel.org>",
        "X-Mailing-List": "netdev@vger.kernel.org"
    },
    "content": "From: Sathya Perla <sathya.perla@broadcom.com>\n\nThis patch adds support for offloading TC based flow\nrules and actions for the 'flower' classifier in the bnxt_en driver.\nIt includes logic to parse flow rules and actions received from the\nTC subsystem, store them and issue the corresponding\nhwrm_cfa_flow_alloc/free FW cmds. L2/IPv4/IPv6 flows and drop,\nredir, vlan push/pop actions are supported in this patch.\n\nIn this patch the hwrm_cfa_flow_xxx routines are just stubs.\nThe code for these routines is introduced in the next patch for easier\nreview. Also, the code to query the TC/flower action stats will\nbe introduced in a subsequent patch.\n\nSigned-off-by: Sathya Perla <sathya.perla@broadcom.com>\nSigned-off-by: Michael Chan <michael.chan@broadcom.com>\n---\n drivers/net/ethernet/broadcom/Kconfig         |   9 +\n drivers/net/ethernet/broadcom/bnxt/Makefile   |   2 +-\n drivers/net/ethernet/broadcom/bnxt/bnxt.c     |  39 +-\n drivers/net/ethernet/broadcom/bnxt/bnxt.h     |  23 +\n drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c  | 602 ++++++++++++++++++++++++++\n drivers/net/ethernet/broadcom/bnxt/bnxt_tc.h  | 158 +++++++\n drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c |  18 +\n drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h |   8 +\n 8 files changed, 850 insertions(+), 9 deletions(-)\n create mode 100644 drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c\n create mode 100644 drivers/net/ethernet/broadcom/bnxt/bnxt_tc.h",
    "diff": "diff --git a/drivers/net/ethernet/broadcom/Kconfig b/drivers/net/ethernet/broadcom/Kconfig\nindex 1456cb1..67134ec 100644\n--- a/drivers/net/ethernet/broadcom/Kconfig\n+++ b/drivers/net/ethernet/broadcom/Kconfig\n@@ -212,6 +212,15 @@ config BNXT_SRIOV\n \t  Virtualization support in the NetXtreme-C/E products. This\n \t  allows for virtual function acceleration in virtual environments.\n \n+config BNXT_FLOWER_OFFLOAD\n+\tbool \"TC Flower offload support for NetXtreme-C/E\"\n+\tdepends on BNXT\n+\tdefault y\n+\t---help---\n+\t  This configuration parameter enables TC Flower packet classifier\n+\t  offload for eswitch.  This option enables SR-IOV switchdev eswitch\n+\t  offload.\n+\n config BNXT_DCB\n \tbool \"Data Center Bridging (DCB) Support\"\n \tdefault n\ndiff --git a/drivers/net/ethernet/broadcom/bnxt/Makefile b/drivers/net/ethernet/broadcom/bnxt/Makefile\nindex d141a22..4f0cb8e 100644\n--- a/drivers/net/ethernet/broadcom/bnxt/Makefile\n+++ b/drivers/net/ethernet/broadcom/bnxt/Makefile\n@@ -1,3 +1,3 @@\n obj-$(CONFIG_BNXT) += bnxt_en.o\n \n-bnxt_en-y := bnxt.o bnxt_sriov.o bnxt_ethtool.o bnxt_dcb.o bnxt_ulp.o bnxt_xdp.o bnxt_vfr.o\n+bnxt_en-y := bnxt.o bnxt_sriov.o bnxt_ethtool.o bnxt_dcb.o bnxt_ulp.o bnxt_xdp.o bnxt_vfr.o bnxt_tc.o\ndiff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c\nindex 4406f91..d6367c1 100644\n--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c\n+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c\n@@ -50,6 +50,7 @@\n #include <linux/bitmap.h>\n #include <linux/cpu_rmap.h>\n #include <linux/cpumask.h>\n+#include <net/pkt_cls.h>\n \n #include \"bnxt_hsi.h\"\n #include \"bnxt.h\"\n@@ -59,6 +60,7 @@\n #include \"bnxt_dcb.h\"\n #include \"bnxt_xdp.h\"\n #include \"bnxt_vfr.h\"\n+#include \"bnxt_tc.h\"\n \n #define BNXT_TX_TIMEOUT\t\t(5 * HZ)\n \n@@ -7305,17 +7307,33 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)\n \treturn 0;\n }\n \n-static int bnxt_setup_tc(struct net_device *dev, enum tc_setup_type type,\n-\t\t\t void *type_data)\n+static int bnxt_setup_flower(struct net_device *dev,\n+\t\t\t     struct tc_cls_flower_offload *cls_flower)\n {\n-\tstruct tc_mqprio_qopt *mqprio = type_data;\n+\tstruct bnxt *bp = netdev_priv(dev);\n \n-\tif (type != TC_SETUP_MQPRIO)\n+\tif (BNXT_VF(bp))\n \t\treturn -EOPNOTSUPP;\n \n-\tmqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS;\n+\treturn bnxt_tc_setup_flower(bp, bp->pf.fw_fid, cls_flower);\n+}\n+\n+static int bnxt_setup_tc(struct net_device *dev, enum tc_setup_type type,\n+\t\t\t void *type_data)\n+{\n+\tswitch (type) {\n+\tcase TC_SETUP_CLSFLOWER:\n+\t\treturn bnxt_setup_flower(dev, type_data);\n+\tcase TC_SETUP_MQPRIO: {\n+\t\tstruct tc_mqprio_qopt *mqprio = type_data;\n+\n+\t\tmqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS;\n \n-\treturn bnxt_setup_mq_tc(dev, mqprio->num_tc);\n+\t\treturn bnxt_setup_mq_tc(dev, mqprio->num_tc);\n+\t}\n+\tdefault:\n+\t\treturn -EOPNOTSUPP;\n+\t}\n }\n \n #ifdef CONFIG_RFS_ACCEL\n@@ -7711,6 +7729,7 @@ static void bnxt_remove_one(struct pci_dev *pdev)\n \n \tpci_disable_pcie_error_reporting(pdev);\n \tunregister_netdev(dev);\n+\tbnxt_shutdown_tc(bp);\n \tcancel_work_sync(&bp->sp_task);\n \tbp->sp_event = 0;\n \n@@ -8102,9 +8121,12 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)\n \telse\n \t\tdevice_set_wakeup_capable(&pdev->dev, false);\n \n+\tif (BNXT_PF(bp))\n+\t\tbnxt_init_tc(bp);\n+\n \trc = register_netdev(dev);\n \tif (rc)\n-\t\tgoto init_err_clr_int;\n+\t\tgoto init_err_cleanup_tc;\n \n \tif (BNXT_PF(bp))\n \t\tbnxt_dl_register(bp);\n@@ -8117,7 +8139,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)\n \n \treturn 0;\n \n-init_err_clr_int:\n+init_err_cleanup_tc:\n+\tbnxt_shutdown_tc(bp);\n \tbnxt_clear_int_mode(bp);\n \n init_err_pci_clean:\ndiff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h\nindex 86af8ea..7b888d4 100644\n--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h\n+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h\n@@ -19,6 +19,7 @@\n #define DRV_VER_UPD\t0\n \n #include <linux/interrupt.h>\n+#include <linux/rhashtable.h>\n #include <net/devlink.h>\n #include <net/dst_metadata.h>\n #include <net/switchdev.h>\n@@ -943,6 +944,27 @@ struct bnxt_test_info {\n #define BNXT_CAG_REG_LEGACY_INT_STATUS\t0x4014\n #define BNXT_CAG_REG_BASE\t\t0x300000\n \n+struct bnxt_tc_info {\n+\tbool\t\t\t\tenabled;\n+\n+\t/* hash table to store TC offloaded flows */\n+\tstruct rhashtable\t\tflow_table;\n+\tstruct rhashtable_params\tflow_ht_params;\n+\n+\t/* hash table to store L2 keys of TC flows */\n+\tstruct rhashtable\t\tl2_table;\n+\tstruct rhashtable_params\tl2_ht_params;\n+\n+\t/* lock to atomically add/del an l2 node when a flow is\n+\t * added or deleted.\n+\t */\n+\tstruct mutex\t\t\tlock;\n+\n+\t/* Stat counter mask (width) */\n+\tu64\t\t\t\tbytes_mask;\n+\tu64\t\t\t\tpackets_mask;\n+};\n+\n struct bnxt_vf_rep_stats {\n \tu64\t\t\tpackets;\n \tu64\t\t\tbytes;\n@@ -1289,6 +1311,7 @@ struct bnxt {\n \tenum devlink_eswitch_mode eswitch_mode;\n \tstruct bnxt_vf_rep\t**vf_reps; /* array of vf-rep ptrs */\n \tu16\t\t\t*cfa_code_map; /* cfa_code -> vf_idx map */\n+\tstruct bnxt_tc_info\ttc_info;\n };\n \n #define BNXT_RX_STATS_OFFSET(counter)\t\t\t\\\ndiff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c\nnew file mode 100644\nindex 0000000..a10df27\n--- /dev/null\n+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c\n@@ -0,0 +1,602 @@\n+/* Broadcom NetXtreme-C/E network driver.\n+ *\n+ * Copyright (c) 2017 Broadcom Limited\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation.\n+ */\n+\n+#include <linux/netdevice.h>\n+#include <linux/inetdevice.h>\n+#include <linux/if_vlan.h>\n+#include <net/flow_dissector.h>\n+#include <net/pkt_cls.h>\n+#include <net/tc_act/tc_gact.h>\n+#include <net/tc_act/tc_skbedit.h>\n+#include <net/tc_act/tc_mirred.h>\n+#include <net/tc_act/tc_vlan.h>\n+\n+#include \"bnxt_hsi.h\"\n+#include \"bnxt.h\"\n+#include \"bnxt_sriov.h\"\n+#include \"bnxt_tc.h\"\n+#include \"bnxt_vfr.h\"\n+\n+#ifdef CONFIG_BNXT_FLOWER_OFFLOAD\n+\n+#define BNXT_FID_INVALID\t\t\t0xffff\n+#define VLAN_TCI(vid, prio)\t((vid) | ((prio) << VLAN_PRIO_SHIFT))\n+\n+/* Return the dst fid of the func for flow forwarding\n+ * For PFs: src_fid is the fid of the PF\n+ * For VF-reps: src_fid the fid of the VF\n+ */\n+static u16 bnxt_flow_get_dst_fid(struct bnxt *pf_bp, struct net_device *dev)\n+{\n+\tstruct bnxt *bp;\n+\n+\t/* check if dev belongs to the same switch */\n+\tif (!switchdev_port_same_parent_id(pf_bp->dev, dev)) {\n+\t\tnetdev_info(pf_bp->dev, \"dev(ifindex=%d) not on same switch\",\n+\t\t\t    dev->ifindex);\n+\t\treturn BNXT_FID_INVALID;\n+\t}\n+\n+\t/* Is dev a VF-rep? */\n+\tif (dev != pf_bp->dev)\n+\t\treturn bnxt_vf_rep_get_fid(dev);\n+\n+\tbp = netdev_priv(dev);\n+\treturn bp->pf.fw_fid;\n+}\n+\n+static int bnxt_tc_parse_redir(struct bnxt *bp,\n+\t\t\t       struct bnxt_tc_actions *actions,\n+\t\t\t       const struct tc_action *tc_act)\n+{\n+\tint ifindex = tcf_mirred_ifindex(tc_act);\n+\tstruct net_device *dev;\n+\tu16 dst_fid;\n+\n+\tdev = __dev_get_by_index(dev_net(bp->dev), ifindex);\n+\tif (!dev) {\n+\t\tnetdev_info(bp->dev, \"no dev for ifindex=%d\", ifindex);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* find the FID from dev */\n+\tdst_fid = bnxt_flow_get_dst_fid(bp, dev);\n+\tif (dst_fid == BNXT_FID_INVALID) {\n+\t\tnetdev_info(bp->dev, \"can't get fid for ifindex=%d\", ifindex);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tactions->flags |= BNXT_TC_ACTION_FLAG_FWD;\n+\tactions->dst_fid = dst_fid;\n+\tactions->dst_dev = dev;\n+\treturn 0;\n+}\n+\n+static void bnxt_tc_parse_vlan(struct bnxt *bp,\n+\t\t\t       struct bnxt_tc_actions *actions,\n+\t\t\t       const struct tc_action *tc_act)\n+{\n+\tif (tcf_vlan_action(tc_act) == TCA_VLAN_ACT_POP) {\n+\t\tactions->flags |= BNXT_TC_ACTION_FLAG_POP_VLAN;\n+\t} else if (tcf_vlan_action(tc_act) == TCA_VLAN_ACT_PUSH) {\n+\t\tactions->flags |= BNXT_TC_ACTION_FLAG_PUSH_VLAN;\n+\t\tactions->push_vlan_tci = htons(tcf_vlan_push_vid(tc_act));\n+\t\tactions->push_vlan_tpid = tcf_vlan_push_proto(tc_act);\n+\t}\n+}\n+\n+static int bnxt_tc_parse_actions(struct bnxt *bp,\n+\t\t\t\t struct bnxt_tc_actions *actions,\n+\t\t\t\t struct tcf_exts *tc_exts)\n+{\n+\tconst struct tc_action *tc_act;\n+\tLIST_HEAD(tc_actions);\n+\tint rc;\n+\n+\tif (!tcf_exts_has_actions(tc_exts)) {\n+\t\tnetdev_info(bp->dev, \"no actions\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\ttcf_exts_to_list(tc_exts, &tc_actions);\n+\tlist_for_each_entry(tc_act, &tc_actions, list) {\n+\t\t/* Drop action */\n+\t\tif (is_tcf_gact_shot(tc_act)) {\n+\t\t\tactions->flags |= BNXT_TC_ACTION_FLAG_DROP;\n+\t\t\treturn 0; /* don't bother with other actions */\n+\t\t}\n+\n+\t\t/* Redirect action */\n+\t\tif (is_tcf_mirred_egress_redirect(tc_act)) {\n+\t\t\trc = bnxt_tc_parse_redir(bp, actions, tc_act);\n+\t\t\tif (rc)\n+\t\t\t\treturn rc;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\t/* Push/pop VLAN */\n+\t\tif (is_tcf_vlan(tc_act)) {\n+\t\t\tbnxt_tc_parse_vlan(bp, actions, tc_act);\n+\t\t\tcontinue;\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n+#define GET_KEY(flow_cmd, key_type)\t\t\t\t\t\\\n+\t\tskb_flow_dissector_target((flow_cmd)->dissector, key_type,\\\n+\t\t\t\t\t  (flow_cmd)->key)\n+#define GET_MASK(flow_cmd, key_type)\t\t\t\t\t\\\n+\t\tskb_flow_dissector_target((flow_cmd)->dissector, key_type,\\\n+\t\t\t\t\t  (flow_cmd)->mask)\n+\n+static int bnxt_tc_parse_flow(struct bnxt *bp,\n+\t\t\t      struct tc_cls_flower_offload *tc_flow_cmd,\n+\t\t\t      struct bnxt_tc_flow *flow)\n+{\n+\tstruct flow_dissector *dissector = tc_flow_cmd->dissector;\n+\tu16 addr_type = 0;\n+\n+\t/* KEY_CONTROL and KEY_BASIC are needed for forming a meaningful key */\n+\tif ((dissector->used_keys & BIT(FLOW_DISSECTOR_KEY_CONTROL)) == 0 ||\n+\t    (dissector->used_keys & BIT(FLOW_DISSECTOR_KEY_BASIC)) == 0) {\n+\t\tnetdev_info(bp->dev, \"cannot form TC key: used_keys = 0x%x\",\n+\t\t\t    dissector->used_keys);\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\tif (dissector_uses_key(dissector, FLOW_DISSECTOR_KEY_CONTROL)) {\n+\t\tstruct flow_dissector_key_control *key =\n+\t\t\tGET_KEY(tc_flow_cmd, FLOW_DISSECTOR_KEY_CONTROL);\n+\n+\t\taddr_type = key->addr_type;\n+\t}\n+\n+\tif (dissector_uses_key(dissector, FLOW_DISSECTOR_KEY_BASIC)) {\n+\t\tstruct flow_dissector_key_basic *key =\n+\t\t\tGET_KEY(tc_flow_cmd, FLOW_DISSECTOR_KEY_BASIC);\n+\t\tstruct flow_dissector_key_basic *mask =\n+\t\t\tGET_MASK(tc_flow_cmd, FLOW_DISSECTOR_KEY_BASIC);\n+\n+\t\tflow->l2_key.ether_type = key->n_proto;\n+\t\tflow->l2_mask.ether_type = mask->n_proto;\n+\n+\t\tif (key->n_proto == htons(ETH_P_IP) ||\n+\t\t    key->n_proto == htons(ETH_P_IPV6)) {\n+\t\t\tflow->l4_key.ip_proto = key->ip_proto;\n+\t\t\tflow->l4_mask.ip_proto = mask->ip_proto;\n+\t\t}\n+\t}\n+\n+\tif (dissector_uses_key(dissector, FLOW_DISSECTOR_KEY_ETH_ADDRS)) {\n+\t\tstruct flow_dissector_key_eth_addrs *key =\n+\t\t\tGET_KEY(tc_flow_cmd, FLOW_DISSECTOR_KEY_ETH_ADDRS);\n+\t\tstruct flow_dissector_key_eth_addrs *mask =\n+\t\t\tGET_MASK(tc_flow_cmd, FLOW_DISSECTOR_KEY_ETH_ADDRS);\n+\n+\t\tflow->flags |= BNXT_TC_FLOW_FLAGS_ETH_ADDRS;\n+\t\tether_addr_copy(flow->l2_key.dmac, key->dst);\n+\t\tether_addr_copy(flow->l2_mask.dmac, mask->dst);\n+\t\tether_addr_copy(flow->l2_key.smac, key->src);\n+\t\tether_addr_copy(flow->l2_mask.smac, mask->src);\n+\t}\n+\n+\tif (dissector_uses_key(dissector, FLOW_DISSECTOR_KEY_VLAN)) {\n+\t\tstruct flow_dissector_key_vlan *key =\n+\t\t\tGET_KEY(tc_flow_cmd, FLOW_DISSECTOR_KEY_VLAN);\n+\t\tstruct flow_dissector_key_vlan *mask =\n+\t\t\tGET_MASK(tc_flow_cmd, FLOW_DISSECTOR_KEY_VLAN);\n+\n+\t\tflow->l2_key.inner_vlan_tci =\n+\t\t   cpu_to_be16(VLAN_TCI(key->vlan_id, key->vlan_priority));\n+\t\tflow->l2_mask.inner_vlan_tci =\n+\t\t   cpu_to_be16((VLAN_TCI(mask->vlan_id, mask->vlan_priority)));\n+\t\tflow->l2_key.inner_vlan_tpid = htons(ETH_P_8021Q);\n+\t\tflow->l2_mask.inner_vlan_tpid = htons(0xffff);\n+\t\tflow->l2_key.num_vlans = 1;\n+\t}\n+\n+\tif (dissector_uses_key(dissector, FLOW_DISSECTOR_KEY_IPV4_ADDRS)) {\n+\t\tstruct flow_dissector_key_ipv4_addrs *key =\n+\t\t\tGET_KEY(tc_flow_cmd, FLOW_DISSECTOR_KEY_IPV4_ADDRS);\n+\t\tstruct flow_dissector_key_ipv4_addrs *mask =\n+\t\t\tGET_MASK(tc_flow_cmd, FLOW_DISSECTOR_KEY_IPV4_ADDRS);\n+\n+\t\tflow->flags |= BNXT_TC_FLOW_FLAGS_IPV4_ADDRS;\n+\t\tflow->l3_key.ipv4.daddr.s_addr = key->dst;\n+\t\tflow->l3_mask.ipv4.daddr.s_addr = mask->dst;\n+\t\tflow->l3_key.ipv4.saddr.s_addr = key->src;\n+\t\tflow->l3_mask.ipv4.saddr.s_addr = mask->src;\n+\t} else if (dissector_uses_key(dissector,\n+\t\t\t\t      FLOW_DISSECTOR_KEY_IPV6_ADDRS)) {\n+\t\tstruct flow_dissector_key_ipv6_addrs *key =\n+\t\t\tGET_KEY(tc_flow_cmd, FLOW_DISSECTOR_KEY_IPV6_ADDRS);\n+\t\tstruct flow_dissector_key_ipv6_addrs *mask =\n+\t\t\tGET_MASK(tc_flow_cmd, FLOW_DISSECTOR_KEY_IPV6_ADDRS);\n+\n+\t\tflow->flags |= BNXT_TC_FLOW_FLAGS_IPV6_ADDRS;\n+\t\tflow->l3_key.ipv6.daddr = key->dst;\n+\t\tflow->l3_mask.ipv6.daddr = mask->dst;\n+\t\tflow->l3_key.ipv6.saddr = key->src;\n+\t\tflow->l3_mask.ipv6.saddr = mask->src;\n+\t}\n+\n+\tif (dissector_uses_key(dissector, FLOW_DISSECTOR_KEY_PORTS)) {\n+\t\tstruct flow_dissector_key_ports *key =\n+\t\t\tGET_KEY(tc_flow_cmd, FLOW_DISSECTOR_KEY_PORTS);\n+\t\tstruct flow_dissector_key_ports *mask =\n+\t\t\tGET_MASK(tc_flow_cmd, FLOW_DISSECTOR_KEY_PORTS);\n+\n+\t\tflow->flags |= BNXT_TC_FLOW_FLAGS_PORTS;\n+\t\tflow->l4_key.ports.dport = key->dst;\n+\t\tflow->l4_mask.ports.dport = mask->dst;\n+\t\tflow->l4_key.ports.sport = key->src;\n+\t\tflow->l4_mask.ports.sport = mask->src;\n+\t}\n+\n+\tif (dissector_uses_key(dissector, FLOW_DISSECTOR_KEY_ICMP)) {\n+\t\tstruct flow_dissector_key_icmp *key =\n+\t\t\tGET_KEY(tc_flow_cmd, FLOW_DISSECTOR_KEY_ICMP);\n+\t\tstruct flow_dissector_key_icmp *mask =\n+\t\t\tGET_MASK(tc_flow_cmd, FLOW_DISSECTOR_KEY_ICMP);\n+\n+\t\tflow->flags |= BNXT_TC_FLOW_FLAGS_ICMP;\n+\t\tflow->l4_key.icmp.type = key->type;\n+\t\tflow->l4_key.icmp.code = key->code;\n+\t\tflow->l4_mask.icmp.type = mask->type;\n+\t\tflow->l4_mask.icmp.code = mask->code;\n+\t}\n+\n+\treturn bnxt_tc_parse_actions(bp, &flow->actions, tc_flow_cmd->exts);\n+}\n+\n+static int bnxt_hwrm_cfa_flow_free(struct bnxt *bp, __le16 flow_handle)\n+{\n+\treturn 0;\n+}\n+\n+static int bnxt_hwrm_cfa_flow_alloc(struct bnxt *bp, struct bnxt_tc_flow *flow,\n+\t\t\t\t    __le16 ref_flow_handle, __le16 *flow_handle)\n+{\n+\treturn 0;\n+}\n+\n+static int bnxt_tc_put_l2_node(struct bnxt *bp,\n+\t\t\t       struct bnxt_tc_flow_node *flow_node)\n+{\n+\tstruct bnxt_tc_l2_node *l2_node = flow_node->l2_node;\n+\tstruct bnxt_tc_info *tc_info = &bp->tc_info;\n+\tint rc;\n+\n+\t/* remove flow_node from the L2 shared flow list */\n+\tlist_del(&flow_node->l2_list_node);\n+\tif (--l2_node->refcount == 0) {\n+\t\trc =  rhashtable_remove_fast(&tc_info->l2_table, &l2_node->node,\n+\t\t\t\t\t     tc_info->l2_ht_params);\n+\t\tif (rc)\n+\t\t\tnetdev_err(bp->dev,\n+\t\t\t\t   \"Error: %s: rhashtable_remove_fast: %d\",\n+\t\t\t\t   __func__, rc);\n+\t\tkfree_rcu(l2_node, rcu);\n+\t}\n+\treturn 0;\n+}\n+\n+static struct bnxt_tc_l2_node *\n+bnxt_tc_get_l2_node(struct bnxt *bp, struct rhashtable *l2_table,\n+\t\t    struct rhashtable_params ht_params,\n+\t\t    struct bnxt_tc_l2_key *l2_key)\n+{\n+\tstruct bnxt_tc_l2_node *l2_node;\n+\tint rc;\n+\n+\tl2_node = rhashtable_lookup_fast(l2_table, l2_key, ht_params);\n+\tif (!l2_node) {\n+\t\tl2_node = kzalloc(sizeof(*l2_node), GFP_KERNEL);\n+\t\tif (!l2_node) {\n+\t\t\trc = -ENOMEM;\n+\t\t\treturn NULL;\n+\t\t}\n+\n+\t\tl2_node->key = *l2_key;\n+\t\trc = rhashtable_insert_fast(l2_table, &l2_node->node,\n+\t\t\t\t\t    ht_params);\n+\t\tif (rc) {\n+\t\t\tkfree(l2_node);\n+\t\t\tnetdev_err(bp->dev,\n+\t\t\t\t   \"Error: %s: rhashtable_insert_fast: %d\",\n+\t\t\t\t   __func__, rc);\n+\t\t\treturn NULL;\n+\t\t}\n+\t\tINIT_LIST_HEAD(&l2_node->common_l2_flows);\n+\t}\n+\treturn l2_node;\n+}\n+\n+/* Get the ref_flow_handle for a flow by checking if there are any other\n+ * flows that share the same L2 key as this flow.\n+ */\n+static int\n+bnxt_tc_get_ref_flow_handle(struct bnxt *bp, struct bnxt_tc_flow *flow,\n+\t\t\t    struct bnxt_tc_flow_node *flow_node,\n+\t\t\t    __le16 *ref_flow_handle)\n+{\n+\tstruct bnxt_tc_info *tc_info = &bp->tc_info;\n+\tstruct bnxt_tc_flow_node *ref_flow_node;\n+\tstruct bnxt_tc_l2_node *l2_node;\n+\n+\tl2_node = bnxt_tc_get_l2_node(bp, &tc_info->l2_table,\n+\t\t\t\t      tc_info->l2_ht_params,\n+\t\t\t\t      &flow->l2_key);\n+\tif (!l2_node)\n+\t\treturn -1;\n+\n+\t/* If any other flow is using this l2_node, use it's flow_handle\n+\t * as the ref_flow_handle\n+\t */\n+\tif (l2_node->refcount > 0) {\n+\t\tref_flow_node = list_first_entry(&l2_node->common_l2_flows,\n+\t\t\t\t\t\t struct bnxt_tc_flow_node,\n+\t\t\t\t\t\t l2_list_node);\n+\t\t*ref_flow_handle = ref_flow_node->flow_handle;\n+\t} else {\n+\t\t*ref_flow_handle = cpu_to_le16(0xffff);\n+\t}\n+\n+\t/* Insert the l2_node into the flow_node so that subsequent flows\n+\t * with a matching l2 key can use the flow_handle of this flow\n+\t * as their ref_flow_handle\n+\t */\n+\tflow_node->l2_node = l2_node;\n+\tlist_add(&flow_node->l2_list_node, &l2_node->common_l2_flows);\n+\tl2_node->refcount++;\n+\treturn 0;\n+}\n+\n+/* After the flow parsing is done, this routine is used for checking\n+ * if there are any aspects of the flow that prevent it from being\n+ * offloaded.\n+ */\n+static bool bnxt_tc_can_offload(struct bnxt *bp, struct bnxt_tc_flow *flow)\n+{\n+\t/* If L4 ports are specified then ip_proto must be TCP or UDP */\n+\tif ((flow->flags & BNXT_TC_FLOW_FLAGS_PORTS) &&\n+\t    (flow->l4_key.ip_proto != IPPROTO_TCP &&\n+\t     flow->l4_key.ip_proto != IPPROTO_UDP)) {\n+\t\tnetdev_info(bp->dev, \"Cannot offload non-TCP/UDP (%d) ports\",\n+\t\t\t    flow->l4_key.ip_proto);\n+\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\n+\n+static int __bnxt_tc_del_flow(struct bnxt *bp,\n+\t\t\t      struct bnxt_tc_flow_node *flow_node)\n+{\n+\tstruct bnxt_tc_info *tc_info = &bp->tc_info;\n+\tint rc;\n+\n+\t/* send HWRM cmd to free the flow-id */\n+\tbnxt_hwrm_cfa_flow_free(bp, flow_node->flow_handle);\n+\n+\tmutex_lock(&tc_info->lock);\n+\n+\t/* release reference to l2 node */\n+\tbnxt_tc_put_l2_node(bp, flow_node);\n+\n+\tmutex_unlock(&tc_info->lock);\n+\n+\trc = rhashtable_remove_fast(&tc_info->flow_table, &flow_node->node,\n+\t\t\t\t    tc_info->flow_ht_params);\n+\tif (rc)\n+\t\tnetdev_err(bp->dev, \"Error: %s: rhashtable_remove_fast rc=%d\",\n+\t\t\t   __func__, rc);\n+\n+\tkfree_rcu(flow_node, rcu);\n+\treturn 0;\n+}\n+\n+/* Add a new flow or replace an existing flow.\n+ * Notes on locking:\n+ * There are essentially two critical sections here.\n+ * 1. while adding a new flow\n+ *    a) lookup l2-key\n+ *    b) issue HWRM cmd and get flow_handle\n+ *    c) link l2-key with flow\n+ * 2. while deleting a flow\n+ *    a) unlinking l2-key from flow\n+ * A lock is needed to protect these two critical sections.\n+ *\n+ * The hash-tables are already protected by the rhashtable API.\n+ */\n+static int bnxt_tc_add_flow(struct bnxt *bp, u16 src_fid,\n+\t\t\t    struct tc_cls_flower_offload *tc_flow_cmd)\n+{\n+\tstruct bnxt_tc_flow_node *new_node, *old_node;\n+\tstruct bnxt_tc_info *tc_info = &bp->tc_info;\n+\tstruct bnxt_tc_flow *flow;\n+\t__le16 ref_flow_handle;\n+\tint rc;\n+\n+\t/* allocate memory for the new flow and it's node */\n+\tnew_node = kzalloc(sizeof(*new_node), GFP_KERNEL);\n+\tif (!new_node) {\n+\t\trc = -ENOMEM;\n+\t\tgoto done;\n+\t}\n+\tnew_node->cookie = tc_flow_cmd->cookie;\n+\tflow = &new_node->flow;\n+\n+\trc = bnxt_tc_parse_flow(bp, tc_flow_cmd, flow);\n+\tif (rc)\n+\t\tgoto free_node;\n+\tflow->src_fid = src_fid;\n+\n+\tif (!bnxt_tc_can_offload(bp, flow)) {\n+\t\trc = -ENOSPC;\n+\t\tgoto free_node;\n+\t}\n+\n+\t/* If a flow exists with the same cookie, delete it */\n+\told_node = rhashtable_lookup_fast(&tc_info->flow_table,\n+\t\t\t\t\t  &tc_flow_cmd->cookie,\n+\t\t\t\t\t  tc_info->flow_ht_params);\n+\tif (old_node)\n+\t\t__bnxt_tc_del_flow(bp, old_node);\n+\n+\t/* Check if the L2 part of the flow has been offloaded already.\n+\t * If so, bump up it's refcnt and get it's reference handle.\n+\t */\n+\tmutex_lock(&tc_info->lock);\n+\trc = bnxt_tc_get_ref_flow_handle(bp, flow, new_node, &ref_flow_handle);\n+\tif (rc)\n+\t\tgoto unlock;\n+\n+\t/* send HWRM cmd to alloc the flow */\n+\trc = bnxt_hwrm_cfa_flow_alloc(bp, flow, ref_flow_handle,\n+\t\t\t\t      &new_node->flow_handle);\n+\tif (rc)\n+\t\tgoto put_l2;\n+\n+\t/* add new flow to flow-table */\n+\trc = rhashtable_insert_fast(&tc_info->flow_table, &new_node->node,\n+\t\t\t\t    tc_info->flow_ht_params);\n+\tif (rc)\n+\t\tgoto hwrm_flow_free;\n+\n+\tmutex_unlock(&tc_info->lock);\n+\treturn 0;\n+\n+hwrm_flow_free:\n+\tbnxt_hwrm_cfa_flow_free(bp, new_node->flow_handle);\n+put_l2:\n+\tbnxt_tc_put_l2_node(bp, new_node);\n+unlock:\n+\tmutex_unlock(&tc_info->lock);\n+free_node:\n+\tkfree(new_node);\n+done:\n+\tnetdev_err(bp->dev, \"Error: %s: cookie=0x%lx error=%d\",\n+\t\t   __func__, tc_flow_cmd->cookie, rc);\n+\treturn rc;\n+}\n+\n+static int bnxt_tc_del_flow(struct bnxt *bp,\n+\t\t\t    struct tc_cls_flower_offload *tc_flow_cmd)\n+{\n+\tstruct bnxt_tc_info *tc_info = &bp->tc_info;\n+\tstruct bnxt_tc_flow_node *flow_node;\n+\n+\tflow_node = rhashtable_lookup_fast(&tc_info->flow_table,\n+\t\t\t\t\t   &tc_flow_cmd->cookie,\n+\t\t\t\t\t   tc_info->flow_ht_params);\n+\tif (!flow_node) {\n+\t\tnetdev_info(bp->dev, \"ERROR: no flow_node for cookie %lx\",\n+\t\t\t    tc_flow_cmd->cookie);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn __bnxt_tc_del_flow(bp, flow_node);\n+}\n+\n+static int bnxt_tc_get_flow_stats(struct bnxt *bp,\n+\t\t\t\t  struct tc_cls_flower_offload *tc_flow_cmd)\n+{\n+\treturn 0;\n+}\n+\n+int bnxt_tc_setup_flower(struct bnxt *bp, u16 src_fid,\n+\t\t\t struct tc_cls_flower_offload *cls_flower)\n+{\n+\tint rc = 0;\n+\n+\tswitch (cls_flower->command) {\n+\tcase TC_CLSFLOWER_REPLACE:\n+\t\trc = bnxt_tc_add_flow(bp, src_fid, cls_flower);\n+\t\tbreak;\n+\n+\tcase TC_CLSFLOWER_DESTROY:\n+\t\trc = bnxt_tc_del_flow(bp, cls_flower);\n+\t\tbreak;\n+\n+\tcase TC_CLSFLOWER_STATS:\n+\t\trc = bnxt_tc_get_flow_stats(bp, cls_flower);\n+\t\tbreak;\n+\t}\n+\treturn rc;\n+}\n+\n+static const struct rhashtable_params bnxt_tc_flow_ht_params = {\n+\t.head_offset = offsetof(struct bnxt_tc_flow_node, node),\n+\t.key_offset = offsetof(struct bnxt_tc_flow_node, cookie),\n+\t.key_len = sizeof(((struct bnxt_tc_flow_node *)0)->cookie),\n+\t.automatic_shrinking = true\n+};\n+\n+static const struct rhashtable_params bnxt_tc_l2_ht_params = {\n+\t.head_offset = offsetof(struct bnxt_tc_l2_node, node),\n+\t.key_offset = offsetof(struct bnxt_tc_l2_node, key),\n+\t.key_len = BNXT_TC_L2_KEY_LEN,\n+\t.automatic_shrinking = true\n+};\n+\n+/* convert counter width in bits to a mask */\n+#define mask(width)\t\t((u64)~0 >> (64 - (width)))\n+\n+int bnxt_init_tc(struct bnxt *bp)\n+{\n+\tstruct bnxt_tc_info *tc_info = &bp->tc_info;\n+\tint rc;\n+\n+\tif (bp->hwrm_spec_code < 0x10800) {\n+\t\tnetdev_warn(bp->dev,\n+\t\t\t    \"Firmware does not support TC flower offload.\\n\");\n+\t\treturn -ENOTSUPP;\n+\t}\n+\tmutex_init(&tc_info->lock);\n+\n+\t/* Counter widths are programmed by FW */\n+\ttc_info->bytes_mask = mask(36);\n+\ttc_info->packets_mask = mask(28);\n+\n+\ttc_info->flow_ht_params = bnxt_tc_flow_ht_params;\n+\trc = rhashtable_init(&tc_info->flow_table, &tc_info->flow_ht_params);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\ttc_info->l2_ht_params = bnxt_tc_l2_ht_params;\n+\trc = rhashtable_init(&tc_info->l2_table, &tc_info->l2_ht_params);\n+\tif (rc)\n+\t\tgoto destroy_flow_table;\n+\n+\ttc_info->enabled = true;\n+\tbp->dev->hw_features |= NETIF_F_HW_TC;\n+\tbp->dev->features |= NETIF_F_HW_TC;\n+\treturn 0;\n+\n+destroy_flow_table:\n+\trhashtable_destroy(&tc_info->flow_table);\n+\treturn rc;\n+}\n+\n+void bnxt_shutdown_tc(struct bnxt *bp)\n+{\n+\tstruct bnxt_tc_info *tc_info = &bp->tc_info;\n+\n+\tif (!tc_info->enabled)\n+\t\treturn;\n+\n+\trhashtable_destroy(&tc_info->flow_table);\n+\trhashtable_destroy(&tc_info->l2_table);\n+}\n+\n+#else\n+#endif\ndiff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.h\nnew file mode 100644\nindex 0000000..6c4c1ed\n--- /dev/null\n+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.h\n@@ -0,0 +1,158 @@\n+/* Broadcom NetXtreme-C/E network driver.\n+ *\n+ * Copyright (c) 2017 Broadcom Limited\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation.\n+ */\n+\n+#ifndef BNXT_TC_H\n+#define BNXT_TC_H\n+\n+#ifdef CONFIG_BNXT_FLOWER_OFFLOAD\n+\n+/* Structs used for storing the filter/actions of the TC cmd.\n+ */\n+struct bnxt_tc_l2_key {\n+\tu8\t\tdmac[ETH_ALEN];\n+\tu8\t\tsmac[ETH_ALEN];\n+\t__be16\t\tinner_vlan_tpid;\n+\t__be16\t\tinner_vlan_tci;\n+\t__be16\t\tether_type;\n+\tu8\t\tnum_vlans;\n+};\n+\n+struct bnxt_tc_l3_key {\n+\tunion {\n+\t\tstruct {\n+\t\t\tstruct in_addr daddr;\n+\t\t\tstruct in_addr saddr;\n+\t\t} ipv4;\n+\t\tstruct {\n+\t\t\tstruct in6_addr daddr;\n+\t\t\tstruct in6_addr saddr;\n+\t\t} ipv6;\n+\t};\n+};\n+\n+struct bnxt_tc_l4_key {\n+\tu8  ip_proto;\n+\tunion {\n+\t\tstruct {\n+\t\t\t__be16 sport;\n+\t\t\t__be16 dport;\n+\t\t} ports;\n+\t\tstruct {\n+\t\t\tu8 type;\n+\t\t\tu8 code;\n+\t\t} icmp;\n+\t};\n+};\n+\n+struct bnxt_tc_actions {\n+\tu32\t\t\t\tflags;\n+#define BNXT_TC_ACTION_FLAG_FWD\t\t\tBIT(0)\n+#define BNXT_TC_ACTION_FLAG_FWD_VXLAN\t\tBIT(1)\n+#define BNXT_TC_ACTION_FLAG_PUSH_VLAN\t\tBIT(3)\n+#define BNXT_TC_ACTION_FLAG_POP_VLAN\t\tBIT(4)\n+#define BNXT_TC_ACTION_FLAG_DROP\t\tBIT(5)\n+\n+\tu16\t\t\t\tdst_fid;\n+\tstruct net_device\t\t*dst_dev;\n+\t__be16\t\t\t\tpush_vlan_tpid;\n+\t__be16\t\t\t\tpush_vlan_tci;\n+};\n+\n+struct bnxt_tc_flow_stats {\n+\tu64\t\tpackets;\n+\tu64\t\tbytes;\n+};\n+\n+struct bnxt_tc_flow {\n+\tu32\t\t\t\tflags;\n+#define BNXT_TC_FLOW_FLAGS_ETH_ADDRS\t\tBIT(1)\n+#define BNXT_TC_FLOW_FLAGS_IPV4_ADDRS\t\tBIT(2)\n+#define BNXT_TC_FLOW_FLAGS_IPV6_ADDRS\t\tBIT(3)\n+#define BNXT_TC_FLOW_FLAGS_PORTS\t\tBIT(4)\n+#define BNXT_TC_FLOW_FLAGS_ICMP\t\t\tBIT(5)\n+\n+\t/* flow applicable to pkts ingressing on this fid */\n+\tu16\t\t\t\tsrc_fid;\n+\tstruct bnxt_tc_l2_key\t\tl2_key;\n+\tstruct bnxt_tc_l2_key\t\tl2_mask;\n+\tstruct bnxt_tc_l3_key\t\tl3_key;\n+\tstruct bnxt_tc_l3_key\t\tl3_mask;\n+\tstruct bnxt_tc_l4_key\t\tl4_key;\n+\tstruct bnxt_tc_l4_key\t\tl4_mask;\n+\n+\tstruct bnxt_tc_actions\t\tactions;\n+\n+\t/* updated stats accounting for hw-counter wrap-around */\n+\tstruct bnxt_tc_flow_stats\tstats;\n+\t/* previous snap-shot of stats */\n+\tstruct bnxt_tc_flow_stats\tprev_stats;\n+\tunsigned long\t\t\tlastused; /* jiffies */\n+};\n+\n+/* L2 hash table\n+ * This data-struct is used for L2-flow table.\n+ * The L2 part of a flow is stored in a hash table.\n+ * A flow that shares the same L2 key/mask with an\n+ * already existing flow must refer to it's flow handle.\n+ */\n+struct bnxt_tc_l2_node {\n+\t/* hash key: first 16b of key */\n+#define BNXT_TC_L2_KEY_LEN\t\t\t16\n+\tstruct bnxt_tc_l2_key\tkey;\n+\tstruct rhash_head\tnode;\n+\n+\t/* a linked list of flows that share the same l2 key */\n+\tstruct list_head\tcommon_l2_flows;\n+\n+\t/* number of flows sharing the l2 key */\n+\tu16\t\t\trefcount;\n+\n+\tstruct rcu_head\t\trcu;\n+};\n+\n+struct bnxt_tc_flow_node {\n+\t/* hash key: provided by TC */\n+\tunsigned long\t\t\tcookie;\n+\tstruct rhash_head\t\tnode;\n+\n+\tstruct bnxt_tc_flow\t\tflow;\n+\n+\t__le16\t\t\t\tflow_handle;\n+\n+\t/* L2 node in l2 hashtable that shares flow's l2 key */\n+\tstruct bnxt_tc_l2_node\t\t*l2_node;\n+\t/* for the shared_flows list maintained in l2_node */\n+\tstruct list_head\t\tl2_list_node;\n+\n+\tstruct rcu_head\t\t\trcu;\n+};\n+\n+int bnxt_tc_setup_flower(struct bnxt *bp, u16 src_fid,\n+\t\t\t struct tc_cls_flower_offload *cls_flower);\n+int bnxt_init_tc(struct bnxt *bp);\n+void bnxt_shutdown_tc(struct bnxt *bp);\n+\n+#else /* CONFIG_BNXT_FLOWER_OFFLOAD */\n+\n+static inline int bnxt_tc_setup_flower(struct bnxt *bp, u16 src_fid,\n+\t\t\t\t       struct tc_cls_flower_offload *cls_flower)\n+{\n+\treturn -EOPNOTSUPP;\n+}\n+\n+static inline int bnxt_init_tc(struct bnxt *bp)\n+{\n+\treturn 0;\n+}\n+\n+static inline void bnxt_shutdown_tc(struct bnxt *bp)\n+{\n+}\n+#endif /* CONFIG_BNXT_FLOWER_OFFLOAD */\n+#endif /* BNXT_TC_H */\ndiff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c\nindex c365d3c..e75db04 100644\n--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c\n+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c\n@@ -11,10 +11,12 @@\n #include <linux/etherdevice.h>\n #include <linux/rtnetlink.h>\n #include <linux/jhash.h>\n+#include <net/pkt_cls.h>\n \n #include \"bnxt_hsi.h\"\n #include \"bnxt.h\"\n #include \"bnxt_vfr.h\"\n+#include \"bnxt_tc.h\"\n \n #ifdef CONFIG_BNXT_SRIOV\n \n@@ -113,6 +115,21 @@ static netdev_tx_t bnxt_vf_rep_xmit(struct sk_buff *skb,\n \tstats->tx_bytes = vf_rep->tx_stats.bytes;\n }\n \n+static int bnxt_vf_rep_setup_tc(struct net_device *dev, enum tc_setup_type type,\n+\t\t\t\tvoid *type_data)\n+{\n+\tstruct bnxt_vf_rep *vf_rep = netdev_priv(dev);\n+\tstruct bnxt *bp = vf_rep->bp;\n+\tint vf_fid = bp->pf.vf[vf_rep->vf_idx].fw_fid;\n+\n+\tswitch (type) {\n+\tcase TC_SETUP_CLSFLOWER:\n+\t\treturn bnxt_tc_setup_flower(bp, vf_fid, type_data);\n+\tdefault:\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+}\n+\n struct net_device *bnxt_get_vf_rep(struct bnxt *bp, u16 cfa_code)\n {\n \tu16 vf_idx;\n@@ -182,6 +199,7 @@ static int bnxt_vf_rep_port_attr_get(struct net_device *dev,\n \t.ndo_stop\t\t= bnxt_vf_rep_close,\n \t.ndo_start_xmit\t\t= bnxt_vf_rep_xmit,\n \t.ndo_get_stats64\t= bnxt_vf_rep_get_stats64,\n+\t.ndo_setup_tc\t\t= bnxt_vf_rep_setup_tc,\n \t.ndo_get_phys_port_name = bnxt_vf_rep_get_phys_port_name\n };\n \ndiff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h\nindex 3e997c9..d8b5f89 100644\n--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h\n+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h\n@@ -45,6 +45,14 @@ static inline void bnxt_link_bp_to_dl(struct bnxt *bp, struct devlink *dl)\n void bnxt_vf_rep_rx(struct bnxt *bp, struct sk_buff *skb);\n struct net_device *bnxt_get_vf_rep(struct bnxt *bp, u16 cfa_code);\n \n+static inline u16 bnxt_vf_rep_get_fid(struct net_device *dev)\n+{\n+\tstruct bnxt_vf_rep *vf_rep = netdev_priv(dev);\n+\tstruct bnxt *bp = vf_rep->bp;\n+\n+\treturn bp->pf.vf[vf_rep->vf_idx].fw_fid;\n+}\n+\n #else\n \n static inline int bnxt_dl_register(struct bnxt *bp)\n",
    "prefixes": [
        "net-next",
        "09/11"
    ]
}