[11/12] net/ice: add FDIR counter support for flow shared
Checks
Commit Message
Signed-off-by: Yahui Cao <yahui.cao@intel.com>
---
drivers/net/ice/ice_fdir_filter.c | 35 +++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
@@ -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)