+
+static inline int32_t
+ulp_mapper_parent_flow_free(struct bnxt_ulp_context *ulp,
+ uint32_t parent_fid,
+ struct ulp_flow_db_res_params *res)
+{
+ uint32_t idx, child_fid = 0, parent_idx;
+ struct bnxt_ulp_flow_db *flow_db;
+
+ parent_idx = (uint32_t)res->resource_hndl;
+
+ /* check the validity of the parent fid */
+ if (ulp_flow_db_parent_flow_idx_get(ulp, parent_fid, &idx) ||
+ idx != parent_idx) {
+ BNXT_TF_DBG(ERR, "invalid parent flow id %x\n", parent_fid);
+ return -EINVAL;
+ }
+
+ /* Clear all the child flows parent index */
+ flow_db = bnxt_ulp_cntxt_ptr2_flow_db_get(ulp);
+ while (!ulp_flow_db_parent_child_flow_next_entry_get(flow_db, idx,
+ &child_fid)) {
+ /* update the child flows resource handle */
+ if (ulp_flow_db_child_flow_reset(ulp, BNXT_ULP_FDB_TYPE_REGULAR,
+ child_fid)) {
+ BNXT_TF_DBG(ERR, "failed to reset child flow %x\n",
+ child_fid);
+ return -EINVAL;
+ }
+ }
+
+ /* free the parent entry in the parent table flow */
+ if (ulp_flow_db_parent_flow_free(ulp, parent_fid)) {
+ BNXT_TF_DBG(ERR, "failed to free parent flow %x\n", parent_fid);
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static inline int32_t
+ulp_mapper_child_flow_free(struct bnxt_ulp_context *ulp,
+ uint32_t child_fid,
+ struct ulp_flow_db_res_params *res)
+{
+ uint32_t parent_fid;
+
+ parent_fid = (uint32_t)res->resource_hndl;
+ if (!parent_fid)
+ return 0; /* Already freed - orphan child*/
+
+ /* reset the child flow bitset*/
+ if (ulp_flow_db_parent_child_flow_set(ulp, parent_fid, child_fid, 0)) {
+ BNXT_TF_DBG(ERR, "error in resetting child flow bitset %x:%x\n",
+ parent_fid, child_fid);
+ return -EINVAL;
+ }
+ return 0;
+}
+