diff mbox series

[11/12] net/ice: add FDIR counter support for flow shared

Message ID 20190906120058.108073-12-yahui.cao@intel.com (mailing list archive)
State Superseded, archived
Delegated to: xiaolong ye
Headers show
Series net/ice: add ice Flow Director driver | expand

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation fail apply issues

Commit Message

Cao, Yahui Sept. 6, 2019, noon UTC
Signed-off-by: Yahui Cao <yahui.cao@intel.com>
---
 drivers/net/ice/ice_fdir_filter.c | 35 +++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index a2da40f85..b226ea6d2 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -197,6 +197,29 @@  ice_fdir_counter_release(struct ice_pf *pf)
 	return 0;
 }
 
+static struct ice_fdir_counter *
+ice_fdir_counter_shared_search(struct ice_fdir_counter_pool_container
+					*container,
+			       uint32_t id)
+{
+	struct ice_fdir_counter_pool *pool;
+	struct ice_fdir_counter *counter;
+	int i;
+
+	TAILQ_FOREACH(pool, &container->pool_list, next) {
+		for (i = 0; i < ICE_FDIR_COUNTERS_PER_BLOCK; i++) {
+			counter = &pool->counters[i];
+
+			if (counter->shared &&
+			    counter->ref_cnt &&
+			    counter->id == id)
+				return counter;
+		}
+	}
+
+	return NULL;
+}
+
 static void
 ice_release_fdir_filter_list(struct ice_pf *pf)
 {
@@ -218,6 +241,18 @@  ice_fdir_counter_alloc(struct ice_pf *pf, uint32_t shared, uint32_t id)
 	struct ice_fdir_counter_pool *pool = NULL;
 	struct ice_fdir_counter *counter_free = NULL;
 
+	if (shared) {
+		counter_free = ice_fdir_counter_shared_search(container, id);
+		if (counter_free) {
+			if (counter_free->ref_cnt + 1 == 0) {
+				rte_errno = E2BIG;
+				return NULL;
+			}
+			counter_free->ref_cnt++;
+			return counter_free;
+		}
+	}
+
 	TAILQ_FOREACH(pool, &container->pool_list, next) {
 		counter_free = TAILQ_FIRST(&pool->counter_list);
 		if (counter_free)