-/* internal validation function for parent flow tbl */
-static struct bnxt_ulp_flow_db *
-ulp_flow_db_parent_arg_validation(struct bnxt_ulp_context *ulp_ctxt,
- uint32_t fid)
-{
- struct bnxt_ulp_flow_db *flow_db;
-
- flow_db = bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctxt);
- if (!flow_db) {
- BNXT_TF_DBG(ERR, "Invalid Arguments\n");
- return NULL;
- }
-
- /* check for max flows */
- if (fid >= flow_db->flow_tbl.num_flows || !fid) {
- BNXT_TF_DBG(ERR, "Invalid flow index\n");
- return NULL;
- }
-
- /* No support for parent child db then just exit */
- if (!flow_db->parent_child_db.entries_count) {
- BNXT_TF_DBG(ERR, "parent child db not supported\n");
- return NULL;
- }
-
- return flow_db;
-}
-
-/*
- * Set the tunnel index in the parent flow
- *
- * ulp_ctxt [in] Ptr to ulp_context
- * parent_idx [in] The parent index of the parent flow entry
- *
- * returns index on success and negative on failure.
- */
-static int32_t
-ulp_flow_db_parent_tun_idx_set(struct bnxt_ulp_context *ulp_ctxt,
- uint32_t parent_idx, uint8_t tun_idx)
-{
- struct bnxt_ulp_flow_db *flow_db;
- struct ulp_fdb_parent_child_db *p_pdb;
-
- flow_db = bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctxt);
- if (!flow_db) {
- BNXT_TF_DBG(ERR, "Invalid Arguments\n");
- return -EINVAL;
- }
-
- /* check for parent idx validity */
- p_pdb = &flow_db->parent_child_db;
- if (parent_idx >= p_pdb->entries_count ||
- !p_pdb->parent_flow_tbl[parent_idx].parent_fid) {
- BNXT_TF_DBG(ERR, "Invalid parent flow index %x\n", parent_idx);
- return -EINVAL;
- }
-
- p_pdb->parent_flow_tbl[parent_idx].tun_idx = tun_idx;
- return 0;
-}
-
-/*
- * Get the tunnel index from the parent flow
- *
- * ulp_ctxt [in] Ptr to ulp_context
- * parent_fid [in] The flow id of the parent flow entry
- *
- * returns 0 if counter accum is set else -1.
- */
-static int32_t
-ulp_flow_db_parent_tun_idx_get(struct bnxt_ulp_context *ulp_ctxt,
- uint32_t parent_fid, uint8_t *tun_idx)
-{
- struct bnxt_ulp_flow_db *flow_db;
- struct ulp_fdb_parent_child_db *p_pdb;
- uint32_t idx;
-
- /* validate the arguments */
- flow_db = ulp_flow_db_parent_arg_validation(ulp_ctxt, parent_fid);
- if (!flow_db) {
- BNXT_TF_DBG(ERR, "parent child db validation failed\n");
- return -EINVAL;
- }
-
- p_pdb = &flow_db->parent_child_db;
- for (idx = 0; idx < p_pdb->entries_count; idx++) {
- if (p_pdb->parent_flow_tbl[idx].parent_fid == parent_fid) {
- *tun_idx = p_pdb->parent_flow_tbl[idx].tun_idx;
- return 0;
- }
- }
-
- return -EINVAL;
-}
-