DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
To: dev@dpdk.org
Cc: nirranjan@chelsio.com, indranil@chelsio.com
Subject: [dpdk-dev] [PATCH] net/cxgbe: implement reset hit counters for offloaded flows
Date: Sat, 15 Dec 2018 00:31:23 +0530	[thread overview]
Message-ID: <1544814083-2894-1-git-send-email-rahul.lakkireddy@chelsio.com> (raw)

Implement logic to reset hit counters for offloaded flows.

Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
---
 drivers/net/cxgbe/base/t4_tcb.h  |  6 ++++
 drivers/net/cxgbe/cxgbe_filter.c | 49 ++++++++++++++++++++++++++++++++
 drivers/net/cxgbe/cxgbe_filter.h |  2 ++
 drivers/net/cxgbe/cxgbe_flow.c   |  3 ++
 4 files changed, 60 insertions(+)

diff --git a/drivers/net/cxgbe/base/t4_tcb.h b/drivers/net/cxgbe/base/t4_tcb.h
index 68cda7730..3c590e053 100644
--- a/drivers/net/cxgbe/base/t4_tcb.h
+++ b/drivers/net/cxgbe/base/t4_tcb.h
@@ -22,10 +22,16 @@
 #define V_TCB_TIMESTAMP(x) ((x) << S_TCB_TIMESTAMP)
 
 /* 223:192 */
+#define W_TCB_T_RTT_TS_RECENT_AGE    6
 #define S_TCB_T_RTT_TS_RECENT_AGE    0
 #define M_TCB_T_RTT_TS_RECENT_AGE    0xffffffffULL
 #define V_TCB_T_RTT_TS_RECENT_AGE(x) ((x) << S_TCB_T_RTT_TS_RECENT_AGE)
 
+/* 255:224 */
+#define S_TCB_T_RTSEQ_RECENT    0
+#define M_TCB_T_RTSEQ_RECENT    0xffffffffULL
+#define V_TCB_T_RTSEQ_RECENT(x) ((x) << S_TCB_T_RTSEQ_RECENT)
+
 #define S_TF_CCTRL_RFR    62
 
 #endif /* _T4_TCB_DEFS_H */
diff --git a/drivers/net/cxgbe/cxgbe_filter.c b/drivers/net/cxgbe/cxgbe_filter.c
index 3a7912e48..085039e93 100644
--- a/drivers/net/cxgbe/cxgbe_filter.c
+++ b/drivers/net/cxgbe/cxgbe_filter.c
@@ -1304,6 +1304,55 @@ int cxgbe_get_filter_count(struct adapter *adapter, unsigned int fidx,
 	return 0;
 }
 
+/*
+ * Clear the packet count for the specified filter.
+ */
+int cxgbe_clear_filter_count(struct adapter *adapter, unsigned int fidx,
+			     int hash, bool clear_byte)
+{
+	u64 tcb_mask = 0, tcb_val = 0;
+	struct filter_entry *f = NULL;
+	u16 tcb_word = 0;
+
+	if (is_hashfilter(adapter) && hash) {
+		if (fidx >= adapter->tids.ntids)
+			return -ERANGE;
+
+		/* No hitcounts supported for T5 hashfilters */
+		if (is_t5(adapter->params.chip))
+			return 0;
+
+		f = adapter->tids.tid_tab[fidx];
+	} else {
+		if (fidx >= adapter->tids.nftids)
+			return -ERANGE;
+
+		f = &adapter->tids.ftid_tab[fidx];
+	}
+
+	if (!f || !f->valid)
+		return -EINVAL;
+
+	tcb_word = W_TCB_TIMESTAMP;
+	tcb_mask = V_TCB_TIMESTAMP(M_TCB_TIMESTAMP);
+	tcb_val = V_TCB_TIMESTAMP(0ULL);
+
+	set_tcb_field(adapter, f->tid, tcb_word, tcb_mask, tcb_val, 1);
+
+	if (clear_byte) {
+		tcb_word = W_TCB_T_RTT_TS_RECENT_AGE;
+		tcb_mask =
+			V_TCB_T_RTT_TS_RECENT_AGE(M_TCB_T_RTT_TS_RECENT_AGE) |
+			V_TCB_T_RTSEQ_RECENT(M_TCB_T_RTSEQ_RECENT);
+		tcb_val = V_TCB_T_RTT_TS_RECENT_AGE(0ULL) |
+			  V_TCB_T_RTSEQ_RECENT(0ULL);
+
+		set_tcb_field(adapter, f->tid, tcb_word, tcb_mask, tcb_val, 1);
+	}
+
+	return 0;
+}
+
 /**
  * Handle a Hash filter delete reply.
  */
diff --git a/drivers/net/cxgbe/cxgbe_filter.h b/drivers/net/cxgbe/cxgbe_filter.h
index b7bcbf56a..209ede34f 100644
--- a/drivers/net/cxgbe/cxgbe_filter.h
+++ b/drivers/net/cxgbe/cxgbe_filter.h
@@ -267,4 +267,6 @@ void hash_del_filter_rpl(struct adapter *adap,
 int validate_filter(struct adapter *adap, struct ch_filter_specification *fs);
 int cxgbe_get_filter_count(struct adapter *adapter, unsigned int fidx,
 			   u64 *c, int hash, bool get_byte);
+int cxgbe_clear_filter_count(struct adapter *adapter, unsigned int fidx,
+			     int hash, bool clear_byte);
 #endif /* _CXGBE_FILTER_H_ */
diff --git a/drivers/net/cxgbe/cxgbe_flow.c b/drivers/net/cxgbe/cxgbe_flow.c
index 7b87bdf58..7278cb485 100644
--- a/drivers/net/cxgbe/cxgbe_flow.c
+++ b/drivers/net/cxgbe/cxgbe_flow.c
@@ -947,6 +947,7 @@ cxgbe_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow,
 		 const struct rte_flow_action *action, void *data,
 		 struct rte_flow_error *e)
 {
+	struct adapter *adap = ethdev2adap(flow->dev);
 	struct ch_filter_specification fs;
 	struct rte_flow_query_count *c;
 	struct filter_entry *f;
@@ -985,6 +986,8 @@ cxgbe_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow,
 	/* Query was successful */
 	c->bytes_set = 1;
 	c->hits_set = 1;
+	if (c->reset)
+		cxgbe_clear_filter_count(adap, flow->fidx, f->fs.cap, true);
 
 	return 0; /* success / partial_success */
 }
-- 
2.18.0

             reply	other threads:[~2018-12-14 19:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-14 19:01 Rahul Lakkireddy [this message]
2018-12-20 19:23 ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1544814083-2894-1-git-send-email-rahul.lakkireddy@chelsio.com \
    --to=rahul.lakkireddy@chelsio.com \
    --cc=dev@dpdk.org \
    --cc=indranil@chelsio.com \
    --cc=nirranjan@chelsio.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).