src/dpdk/drivers/net/octeontx2/otx2_flow_utils.c
static int
flow_validate_and_shift_prio_ent(struct otx2_mbox *mbox, struct rte_flow *flow,
				 struct otx2_npc_flow_info *flow_info,
				 struct npc_mcam_alloc_entry_rsp *rsp,
				 int req_prio)
{
	int prio_idx = 0, rc = 0, needs_shift = 0, idx, prio = flow->priority;
	struct otx2_mcam_ents_info *info = flow_info->flow_entry_info;
	int dir = (req_prio == NPC_MCAM_HIGHER_PRIO) ? 1 : -1;
	uint32_t tot_ent = 0;

	otx2_npc_dbg("Dir %d, priority = %d", dir, prio);

	if (dir < 0)
		prio_idx = flow_info->flow_max_priority - 1;

	/* Only live entries needs to be shifted, free entries can just be
	 * moved by bits manipulation.
	 */

	/* For dir = -1(NPC_MCAM_LOWER_PRIO), when shifting,
	 * NPC_MAX_PREALLOC_ENT are exchanged with adjoining higher priority
	 * level entries(lower indexes).
	 *
	 * For dir = +1(NPC_MCAM_HIGHER_PRIO), during shift,
	 * NPC_MAX_PREALLOC_ENT are exchanged with adjoining lower priority
	 * level entries(higher indexes) with highest indexes.
	 */
	do {
		tot_ent = info[prio_idx].free_ent + info[prio_idx].live_ent;

		if (dir < 0 && prio_idx != prio &&
		    rsp->entry > info[prio_idx].max_id && tot_ent) {
			otx2_npc_dbg("Rsp entry %u prio idx %u "
				     "max id %u", rsp->entry, prio_idx,
				      info[prio_idx].max_id);

			needs_shift = 1;
		} else if ((dir > 0) && (prio_idx != prio) &&
		     (rsp->entry < info[prio_idx].min_id) && tot_ent) {
			otx2_npc_dbg("Rsp entry %u prio idx %u "
				     "min id %u", rsp->entry, prio_idx,
				      info[prio_idx].min_id);
			needs_shift = 1;
		}

		otx2_npc_dbg("Needs_shift = %d", needs_shift);
		if (needs_shift) {
			needs_shift = 0;
			rc = flow_shift_ent(mbox, flow, flow_info, rsp, dir,
					    prio_idx);
		} else {
			for (idx = 0; idx < rsp->count; idx++)
				rsp->entry_list[idx] = rsp->entry + idx;
		}
	} while ((prio_idx != prio) && (prio_idx += dir));

	return rc;
}
/* Validate if newly allocated entries lie in the correct priority zone
 * since NPC_MCAM_LOWER_PRIO & NPC_MCAM_HIGHER_PRIO don't ensure zone accuracy.
 * If not properly aligned, shift entries to do so
 */
Validate if newly allocated entries lie in the correct priority zone
since NPC_MCAM_LOWER_PRIO & NPC_MCAM_HIGHER_PRIO don't ensure zone accuracy.
If not properly aligned, shift entries to do so
Validate if newly allocated entries lie in the correct priority zone since NPC_MCAM_LOWER_PRIO & NPC_MCAM_HIGHER_PRIO don ' t ensure zone accuracy . If not properly aligned shift entries to do so
static int
flow_validate_and_shift_prio_ent(struct otx2_mbox *mbox, struct rte_flow *flow,
				 struct otx2_npc_flow_info *flow_info,
				 struct npc_mcam_alloc_entry_rsp *rsp,
				 int req_prio)
{
	int prio_idx = 0, rc = 0, needs_shift = 0, idx, prio = flow->priority;
	struct otx2_mcam_ents_info *info = flow_info->flow_entry_info;
	int dir = (req_prio == NPC_MCAM_HIGHER_PRIO) ? 1 : -1;
	uint32_t tot_ent = 0;
	otx2_npc_dbg("Dir %d, priority = %d", dir, prio);
	if (dir < 0)
		prio_idx = flow_info->flow_max_priority - 1;
	do {
		tot_ent = info[prio_idx].free_ent + info[prio_idx].live_ent;
		if (dir < 0 && prio_idx != prio &&
		    rsp->entry > info[prio_idx].max_id && tot_ent) {
			otx2_npc_dbg("Rsp entry %u prio idx %u "
				     "max id %u", rsp->entry, prio_idx,
				      info[prio_idx].max_id);
			needs_shift = 1;
		} else if ((dir > 0) && (prio_idx != prio) &&
		     (rsp->entry < info[prio_idx].min_id) && tot_ent) {
			otx2_npc_dbg("Rsp entry %u prio idx %u "
				     "min id %u", rsp->entry, prio_idx,
				      info[prio_idx].min_id);
			needs_shift = 1;
		}
		otx2_npc_dbg("Needs_shift = %d", needs_shift);
		if (needs_shift) {
			needs_shift = 0;
			rc = flow_shift_ent(mbox, flow, flow_info, rsp, dir,
					    prio_idx);
		} else {
			for (idx = 0; idx < rsp->count; idx++)
				rsp->entry_list[idx] = rsp->entry + idx;
		}
	} while ((prio_idx != prio) && (prio_idx += dir));
	return rc;
}
static int flow_validate_and_shift_prio_ent ( struct otx2_mbox * mbox , struct rte_flow * flow , struct otx2_npc_flow_info * flow_info , struct npc_mcam_alloc_entry_rsp * rsp , int req_prio ) { int prio_idx = 0 , rc = 0 , needs_shift = 0 , idx , prio = flow -> priority ; struct otx2_mcam_ents_info * info = flow_info -> flow_entry_info ; int dir = ( req_prio == NPC_MCAM_HIGHER_PRIO ) ? 1 : -1 ; uint32_t tot_ent = 0 ; otx2_npc_dbg ( " " , dir , prio ) ; if ( dir < 0 ) prio_idx = flow_info -> flow_max_priority - 1 ; do { tot_ent = info [ prio_idx ] . free_ent + info [ prio_idx ] . live_ent ; if ( dir < 0 && prio_idx != prio && rsp -> entry > info [ prio_idx ] . max_id && tot_ent ) { otx2_npc_dbg ( " " " " , rsp -> entry , prio_idx , info [ prio_idx ] . max_id ) ; needs_shift = 1 ; } else if ( ( dir > 0 ) && ( prio_idx != prio ) && ( rsp -> entry < info [ prio_idx ] . min_id ) && tot_ent ) { otx2_npc_dbg ( " " " " , rsp -> entry , prio_idx , info [ prio_idx ] . min_id ) ; needs_shift = 1 ; } otx2_npc_dbg ( " " , needs_shift ) ; if ( needs_shift ) { needs_shift = 0 ; rc = flow_shift_ent ( mbox , flow , flow_info , rsp , dir , prio_idx ) ; } else { for ( idx = 0 ; idx < rsp -> count ; idx ++ ) rsp -> entry_list [ idx ] = rsp -> entry + idx ; } } while ( ( prio_idx != prio ) && ( prio_idx += dir ) ) ; return rc ; }
Validate if newly allocated entries lie in the correct priority zone
 since NPC_MCAM_LOWER_PRIO & NPC_MCAM_HIGHER_PRIO don't ensure zone accuracy.
Validate if newly allocated entries lie in the correct priority zone since NPC_MCAM_LOWER_PRIO & NPC_MCAM_HIGHER_PRIO don ' t ensure zone accuracy .
/* Only live entries needs to be shifted, free entries can just be
	 * moved by bits manipulation.
	 */ /* For dir = -1(NPC_MCAM_LOWER_PRIO), when shifting,
	 * NPC_MAX_PREALLOC_ENT are exchanged with adjoining higher priority
	 * level entries(lower indexes).
	 *
	 * For dir = +1(NPC_MCAM_HIGHER_PRIO), during shift,
	 * NPC_MAX_PREALLOC_ENT are exchanged with adjoining lower priority
	 * level entries(higher indexes) with highest indexes.
	 */