if (!session)
return;
+ /* clean up regular flows */
+ ulp_flow_db_flush_flows(&bp->ulp_ctx, BNXT_ULP_REGULAR_FLOW_TABLE);
+
/* cleanup the eem table scope */
ulp_eem_tbl_scope_deinit(bp, &bp->ulp_ctx);
return ret;
}
+/* Function to destroy the rte flows. */
+static int32_t
+bnxt_ulp_flow_flush(struct rte_eth_dev *eth_dev,
+ struct rte_flow_error *error)
+{
+ struct bnxt_ulp_context *ulp_ctx;
+ int32_t ret;
+ struct bnxt *bp;
+
+ ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(eth_dev);
+ if (!ulp_ctx) {
+ BNXT_TF_DBG(ERR, "ULP context is not initialized\n");
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+ "Failed to flush flow.");
+ return -EINVAL;
+ }
+ bp = eth_dev->data->dev_private;
+
+ /* Free the resources for the last device */
+ if (!ulp_ctx_deinit_allowed(bp))
+ return 0;
+
+ ret = ulp_flow_db_flush_flows(ulp_ctx, BNXT_ULP_REGULAR_FLOW_TABLE);
+ if (ret)
+ rte_flow_error_set(error, ret,
+ RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+ "Failed to flush flow.");
+ return ret;
+}
+
const struct rte_flow_ops bnxt_ulp_rte_flow_ops = {
.validate = bnxt_ulp_flow_validate,
.create = bnxt_ulp_flow_create,
.destroy = bnxt_ulp_flow_destroy,
- .flush = NULL,
+ .flush = bnxt_ulp_flow_flush,
.query = NULL,
.isolate = NULL
};
/* all good, return success */
return 0;
}
+
+/** Get the flow database entry iteratively
+ *
+ * flow_tbl [in] Ptr to flow table
+ * fid [in/out] The index to the flow entry
+ *
+ * returns 0 on success and negative on failure.
+ */
+static int32_t
+ulp_flow_db_next_entry_get(struct bnxt_ulp_flow_tbl *flowtbl,
+ uint32_t *fid)
+{
+ uint32_t lfid = *fid;
+ uint32_t idx;
+ uint64_t bs;
+
+ do {
+ lfid++;
+ if (lfid >= flowtbl->num_flows)
+ return -ENOENT;
+ idx = lfid / ULP_INDEX_BITMAP_SIZE;
+ while (!(bs = flowtbl->active_flow_tbl[idx])) {
+ idx++;
+ if ((idx * ULP_INDEX_BITMAP_SIZE) >= flowtbl->num_flows)
+ return -ENOENT;
+ }
+ lfid = (idx * ULP_INDEX_BITMAP_SIZE) + __builtin_clzl(bs);
+ if (*fid >= lfid) {
+ BNXT_TF_DBG(ERR, "Flow Database is corrupt\n");
+ return -ENOENT;
+ }
+ } while (!ulp_flow_db_active_flow_is_set(flowtbl, lfid));
+
+ /* all good, return success */
+ *fid = lfid;
+ return 0;
+}
+
+/*
+ * Flush all flows in the flow database.
+ *
+ * ulp_ctxt [in] Ptr to ulp context
+ * tbl_idx [in] The index to table
+ *
+ * returns 0 on success or negative number on failure
+ */
+int32_t ulp_flow_db_flush_flows(struct bnxt_ulp_context *ulp_ctx,
+ uint32_t idx)
+{
+ uint32_t fid = 0;
+ struct bnxt_ulp_flow_db *flow_db;
+ struct bnxt_ulp_flow_tbl *flow_tbl;
+
+ if (!ulp_ctx) {
+ BNXT_TF_DBG(ERR, "Invalid Argument\n");
+ return -EINVAL;
+ }
+
+ flow_db = bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctx);
+ if (!flow_db) {
+ BNXT_TF_DBG(ERR, "Flow database not found\n");
+ return -EINVAL;
+ }
+ flow_tbl = &flow_db->flow_tbl[idx];
+ while (!ulp_flow_db_next_entry_get(flow_tbl, &fid))
+ (void)ulp_mapper_resources_free(ulp_ctx, fid, idx);
+
+ return 0;
+}
enum bnxt_ulp_flow_db_tables tbl_idx,
uint32_t fid);
+/*
+ * Flush all flows in the flow database.
+ *
+ * ulp_ctxt [in] Ptr to ulp context
+ * tbl_idx [in] The index to table
+ *
+ * returns 0 on success or negative number on failure
+ */
+int32_t ulp_flow_db_flush_flows(struct bnxt_ulp_context *ulp_ctx,
+ uint32_t idx);
+
#endif /* _ULP_FLOW_DB_H_ */