get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 816732,
    "url": "http://patchwork.ozlabs.org/api/patches/816732/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/63b38f185f893bca43916cb797a8764cb524c7c1.1505977744.git.rahul.lakkireddy@chelsio.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": "<63b38f185f893bca43916cb797a8764cb524c7c1.1505977744.git.rahul.lakkireddy@chelsio.com>",
    "list_archive_url": null,
    "date": "2017-09-21T07:33:37",
    "name": "[net-next,4/4] cxgb4: fetch stats for offloaded tc flower flows",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "7b84b439822384b1b5e20e16e3587567dd3c7366",
    "submitter": {
        "id": 69728,
        "url": "http://patchwork.ozlabs.org/api/people/69728/?format=api",
        "name": "Rahul Lakkireddy",
        "email": "rahul.lakkireddy@chelsio.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/63b38f185f893bca43916cb797a8764cb524c7c1.1505977744.git.rahul.lakkireddy@chelsio.com/mbox/",
    "series": [
        {
            "id": 4320,
            "url": "http://patchwork.ozlabs.org/api/series/4320/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=4320",
            "date": "2017-09-21T07:33:33",
            "name": "cxgb4: add support to offload tc flower",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/4320/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/816732/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/816732/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>)",
        "Received": [
            "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xyT0D6xbKz9sNc\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 21 Sep 2017 17:34:52 +1000 (AEST)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751923AbdIUHet (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 21 Sep 2017 03:34:49 -0400",
            "from stargate.chelsio.com ([12.32.117.8]:32210 \"EHLO\n\tstargate.chelsio.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751911AbdIUHer (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Thu, 21 Sep 2017 03:34:47 -0400",
            "from localhost (scalar.blr.asicdesigners.com [10.193.185.94])\n\tby stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id v8L7YiFr005047; \n\tThu, 21 Sep 2017 00:34:44 -0700"
        ],
        "From": "Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>",
        "To": "netdev@vger.kernel.org",
        "Cc": "davem@davemloft.net, kumaras@chelsio.com, ganeshgr@chelsio.com,\n\tnirranjan@chelsio.com, indranil@chelsio.com,\n\tRahul Lakkireddy <rahul.lakkireddy@chelsio.com>",
        "Subject": "[PATCH net-next 4/4] cxgb4: fetch stats for offloaded tc flower\n\tflows",
        "Date": "Thu, 21 Sep 2017 13:03:37 +0530",
        "Message-Id": "<63b38f185f893bca43916cb797a8764cb524c7c1.1505977744.git.rahul.lakkireddy@chelsio.com>",
        "X-Mailer": "git-send-email 2.5.3",
        "In-Reply-To": [
            "<cover.1505977744.git.rahul.lakkireddy@chelsio.com>",
            "<cover.1505977744.git.rahul.lakkireddy@chelsio.com>"
        ],
        "References": [
            "<cover.1505977744.git.rahul.lakkireddy@chelsio.com>",
            "<cover.1505977744.git.rahul.lakkireddy@chelsio.com>"
        ],
        "Sender": "netdev-owner@vger.kernel.org",
        "Precedence": "bulk",
        "List-ID": "<netdev.vger.kernel.org>",
        "X-Mailing-List": "netdev@vger.kernel.org"
    },
    "content": "From: Kumar Sanghvi <kumaras@chelsio.com>\n\nAdd support to retrieve stats from hardware for offloaded tc flower\nflows.  Also, poll for the stats of offloaded flows via timer callback.\n\nSigned-off-by: Kumar Sanghvi <kumaras@chelsio.com>\nSigned-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>\nSigned-off-by: Ganesh Goudar <ganeshgr@chelsio.com>\n---\n drivers/net/ethernet/chelsio/cxgb4/cxgb4.h         |  1 +\n drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c  | 76 +++++++++++++++++++++\n drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c    |  1 +\n .../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c   | 79 +++++++++++++++++++++-\n .../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h   |  3 +\n drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h     |  2 +\n 6 files changed, 161 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h\nindex 26eac599ab2c..8a94d97df025 100644\n--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h\n+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h\n@@ -907,6 +907,7 @@ struct adapter {\n \n \t/* TC flower offload */\n \tDECLARE_HASHTABLE(flower_anymatch_tbl, 9);\n+\tstruct timer_list flower_stats_timer;\n };\n \n /* Support for \"sched-class\" command to allow a TX Scheduling Class to be\ndiff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c\nindex 07a4619e2164..c09c4de8c9fb 100644\n--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c\n+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c\n@@ -148,6 +148,82 @@ static int get_filter_steerq(struct net_device *dev,\n \treturn iq;\n }\n \n+static int get_filter_count(struct adapter *adapter, unsigned int fidx,\n+\t\t\t    u64 *pkts, u64 *bytes)\n+{\n+\tunsigned int tcb_base, tcbaddr;\n+\tunsigned int word_offset;\n+\tstruct filter_entry *f;\n+\t__be64 be64_byte_count;\n+\tint ret;\n+\n+\ttcb_base = t4_read_reg(adapter, TP_CMM_TCB_BASE_A);\n+\tif ((fidx != (adapter->tids.nftids + adapter->tids.nsftids - 1)) &&\n+\t    fidx >= adapter->tids.nftids)\n+\t\treturn -E2BIG;\n+\n+\tf = &adapter->tids.ftid_tab[fidx];\n+\tif (!f->valid)\n+\t\treturn -EINVAL;\n+\n+\ttcbaddr = tcb_base + f->tid * TCB_SIZE;\n+\n+\tspin_lock(&adapter->win0_lock);\n+\tif (is_t4(adapter->params.chip)) {\n+\t\t__be64 be64_count;\n+\n+\t\t/* T4 doesn't maintain byte counts in hw */\n+\t\t*bytes = 0;\n+\n+\t\t/* Get pkts */\n+\t\tword_offset = 4;\n+\t\tret = t4_memory_rw(adapter, MEMWIN_NIC, MEM_EDC0,\n+\t\t\t\t   tcbaddr + (word_offset * sizeof(__be32)),\n+\t\t\t\t   sizeof(be64_count),\n+\t\t\t\t   (__be32 *)&be64_count,\n+\t\t\t\t   T4_MEMORY_READ);\n+\t\tif (ret < 0)\n+\t\t\tgoto out;\n+\t\t*pkts = be64_to_cpu(be64_count);\n+\t} else {\n+\t\t__be32 be32_count;\n+\n+\t\t/* Get bytes */\n+\t\tword_offset = 4;\n+\t\tret = t4_memory_rw(adapter, MEMWIN_NIC, MEM_EDC0,\n+\t\t\t\t   tcbaddr + (word_offset * sizeof(__be32)),\n+\t\t\t\t   sizeof(be64_byte_count),\n+\t\t\t\t   &be64_byte_count,\n+\t\t\t\t   T4_MEMORY_READ);\n+\t\tif (ret < 0)\n+\t\t\tgoto out;\n+\t\t*bytes = be64_to_cpu(be64_byte_count);\n+\n+\t\t/* Get pkts */\n+\t\tword_offset = 6;\n+\t\tret = t4_memory_rw(adapter, MEMWIN_NIC, MEM_EDC0,\n+\t\t\t\t   tcbaddr + (word_offset * sizeof(__be32)),\n+\t\t\t\t   sizeof(be32_count),\n+\t\t\t\t   &be32_count,\n+\t\t\t\t   T4_MEMORY_READ);\n+\t\tif (ret < 0)\n+\t\t\tgoto out;\n+\t\t*pkts = (u64)be32_to_cpu(be32_count);\n+\t}\n+\n+out:\n+\tspin_unlock(&adapter->win0_lock);\n+\treturn ret;\n+}\n+\n+int cxgb4_get_filter_counters(struct net_device *dev, unsigned int fidx,\n+\t\t\t      u64 *hitcnt, u64 *bytecnt)\n+{\n+\tstruct adapter *adapter = netdev2adap(dev);\n+\n+\treturn get_filter_count(adapter, fidx, hitcnt, bytecnt);\n+}\n+\n int cxgb4_get_free_ftid(struct net_device *dev, int family)\n {\n \tstruct adapter *adap = netdev2adap(dev);\ndiff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c\nindex 3ba4e1ff8486..d634098d52ab 100644\n--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c\n+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c\n@@ -4637,6 +4637,7 @@ static void free_some_resources(struct adapter *adapter)\n \tkvfree(adapter->l2t);\n \tt4_cleanup_sched(adapter);\n \tkvfree(adapter->tids.tid_tab);\n+\tcxgb4_cleanup_tc_flower(adapter);\n \tcxgb4_cleanup_tc_u32(adapter);\n \tkfree(adapter->sge.egr_map);\n \tkfree(adapter->sge.ingr_map);\ndiff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c\nindex fddb0c419edc..7a47d4e88a57 100644\n--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c\n+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c\n@@ -39,9 +39,12 @@\n #include \"cxgb4.h\"\n #include \"cxgb4_tc_flower.h\"\n \n+#define STATS_CHECK_PERIOD (HZ / 2)\n+\n static struct ch_tc_flower_entry *allocate_flower_entry(void)\n {\n \tstruct ch_tc_flower_entry *new = kzalloc(sizeof(*new), GFP_KERNEL);\n+\tspin_lock_init(&new->lock);\n \treturn new;\n }\n \n@@ -369,13 +372,87 @@ int cxgb4_tc_flower_destroy(struct net_device *dev,\n \treturn ret;\n }\n \n+void ch_flower_stats_cb(unsigned long data)\n+{\n+\tstruct adapter *adap = (struct adapter *)data;\n+\tstruct ch_tc_flower_entry *flower_entry;\n+\tstruct ch_tc_flower_stats *ofld_stats;\n+\tunsigned int i;\n+\tu64 packets;\n+\tu64 bytes;\n+\tint ret;\n+\n+\trcu_read_lock();\n+\thash_for_each_rcu(adap->flower_anymatch_tbl, i, flower_entry, link) {\n+\t\tret = cxgb4_get_filter_counters(adap->port[0],\n+\t\t\t\t\t\tflower_entry->filter_id,\n+\t\t\t\t\t\t&packets, &bytes);\n+\t\tif (!ret) {\n+\t\t\tspin_lock(&flower_entry->lock);\n+\t\t\tofld_stats = &flower_entry->stats;\n+\n+\t\t\tif (ofld_stats->prev_packet_count != packets) {\n+\t\t\t\tofld_stats->prev_packet_count = packets;\n+\t\t\t\tofld_stats->last_used = jiffies;\n+\t\t\t}\n+\t\t\tspin_unlock(&flower_entry->lock);\n+\t\t}\n+\t}\n+\trcu_read_unlock();\n+\tmod_timer(&adap->flower_stats_timer, jiffies + STATS_CHECK_PERIOD);\n+}\n+\n int cxgb4_tc_flower_stats(struct net_device *dev,\n \t\t\t  struct tc_cls_flower_offload *cls)\n {\n-\treturn -EOPNOTSUPP;\n+\tstruct adapter *adap = netdev2adap(dev);\n+\tstruct ch_tc_flower_stats *ofld_stats;\n+\tstruct ch_tc_flower_entry *ch_flower;\n+\tu64 packets;\n+\tu64 bytes;\n+\tint ret;\n+\n+\tch_flower = ch_flower_lookup(adap, cls->cookie);\n+\tif (!ch_flower) {\n+\t\tret = -ENOENT;\n+\t\tgoto err;\n+\t}\n+\n+\tret = cxgb4_get_filter_counters(dev, ch_flower->filter_id,\n+\t\t\t\t\t&packets, &bytes);\n+\tif (ret < 0)\n+\t\tgoto err;\n+\n+\tspin_lock_bh(&ch_flower->lock);\n+\tofld_stats = &ch_flower->stats;\n+\tif (ofld_stats->packet_count != packets) {\n+\t\tif (ofld_stats->prev_packet_count != packets)\n+\t\t\tofld_stats->last_used = jiffies;\n+\t\ttcf_exts_stats_update(cls->exts, bytes - ofld_stats->byte_count,\n+\t\t\t\t      packets - ofld_stats->packet_count,\n+\t\t\t\t      ofld_stats->last_used);\n+\n+\t\tofld_stats->packet_count = packets;\n+\t\tofld_stats->byte_count = bytes;\n+\t\tofld_stats->prev_packet_count = packets;\n+\t}\n+\tspin_unlock_bh(&ch_flower->lock);\n+\treturn 0;\n+\n+err:\n+\treturn ret;\n }\n \n void cxgb4_init_tc_flower(struct adapter *adap)\n {\n \thash_init(adap->flower_anymatch_tbl);\n+\tsetup_timer(&adap->flower_stats_timer, ch_flower_stats_cb,\n+\t\t    (unsigned long)adap);\n+\tmod_timer(&adap->flower_stats_timer, jiffies + STATS_CHECK_PERIOD);\n+}\n+\n+void cxgb4_cleanup_tc_flower(struct adapter *adap)\n+{\n+\tif (adap->flower_stats_timer.function)\n+\t\tdel_timer_sync(&adap->flower_stats_timer);\n }\ndiff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h\nindex 6145a9e056eb..604feffc752e 100644\n--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h\n+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h\n@@ -38,6 +38,7 @@\n #include <net/pkt_cls.h>\n \n struct ch_tc_flower_stats {\n+\tu64 prev_packet_count;\n \tu64 packet_count;\n \tu64 byte_count;\n \tu64 last_used;\n@@ -49,6 +50,7 @@ struct ch_tc_flower_entry {\n \tunsigned long tc_flower_cookie;\n \tstruct hlist_node link;\n \tstruct rcu_head rcu;\n+\tspinlock_t lock; /* lock for stats */\n \tu32 filter_id;\n };\n \n@@ -60,4 +62,5 @@ int cxgb4_tc_flower_stats(struct net_device *dev,\n \t\t\t  struct tc_cls_flower_offload *cls);\n \n void cxgb4_init_tc_flower(struct adapter *adap);\n+void cxgb4_cleanup_tc_flower(struct adapter *adap);\n #endif /* __CXGB4_TC_FLOWER_H */\ndiff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h\nindex 88487095d14f..52324c77a4fe 100644\n--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h\n+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h\n@@ -221,6 +221,8 @@ int __cxgb4_del_filter(struct net_device *dev, int filter_id,\n int cxgb4_set_filter(struct net_device *dev, int filter_id,\n \t\t     struct ch_filter_specification *fs);\n int cxgb4_del_filter(struct net_device *dev, int filter_id);\n+int cxgb4_get_filter_counters(struct net_device *dev, unsigned int fidx,\n+\t\t\t      u64 *hitcnt, u64 *bytecnt);\n \n static inline void set_wr_txq(struct sk_buff *skb, int prio, int queue)\n {\n",
    "prefixes": [
        "net-next",
        "4/4"
    ]
}