+struct rte_flow *
+i40e_fdir_entry_pool_get(struct i40e_fdir_info *fdir_info)
+{
+ struct rte_flow *flow = NULL;
+ uint64_t slab = 0;
+ uint32_t pos = 0;
+ uint32_t i = 0;
+ int ret;
+
+ if (fdir_info->fdir_actual_cnt >=
+ fdir_info->fdir_space_size) {
+ PMD_DRV_LOG(ERR, "Fdir space full");
+ return NULL;
+ }
+
+ ret = rte_bitmap_scan(fdir_info->fdir_flow_pool.bitmap, &pos,
+ &slab);
+
+ /* normally this won't happen as the fdir_actual_cnt should be
+ * same with the number of the set bits in fdir_flow_pool,
+ * but anyway handle this error condition here for safe
+ */
+ if (ret == 0) {
+ PMD_DRV_LOG(ERR, "fdir_actual_cnt out of sync");
+ return NULL;
+ }
+
+ i = rte_bsf64(slab);
+ pos += i;
+ rte_bitmap_clear(fdir_info->fdir_flow_pool.bitmap, pos);
+ flow = &fdir_info->fdir_flow_pool.pool[pos].flow;
+
+ memset(flow, 0, sizeof(struct rte_flow));
+
+ return flow;
+}
+
+void
+i40e_fdir_entry_pool_put(struct i40e_fdir_info *fdir_info,
+ struct rte_flow *flow)
+{
+ struct i40e_fdir_entry *f;
+
+ f = FLOW_TO_FLOW_BITMAP(flow);
+ rte_bitmap_set(fdir_info->fdir_flow_pool.bitmap, f->idx);
+}
+