- uint32_t index = TF_RESC_TYPE_HW_EM_PROF_ID;
- uint32_t end = 0;
-
- /* em prof id rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_EM_PROF_ID,
- tfs->TF_EM_PROF_ID_POOL_NAME_RX);
-
- /* em prof id tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_EM_PROF_ID,
- tfs->TF_EM_PROF_ID_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the wildcard tcam and profile id
- * resources that Truflow does not own.
- */
-static void
-tf_rm_rsvd_wc(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_HW_WC_TCAM_PROF_ID;
- uint32_t end = 0;
-
- /* wc profile id rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_WC_PROF_ID,
- tfs->TF_WC_TCAM_PROF_ID_POOL_NAME_RX);
-
- /* wc profile id tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_WC_PROF_ID,
- tfs->TF_WC_TCAM_PROF_ID_POOL_NAME_TX);
-
- index = TF_RESC_TYPE_HW_WC_TCAM;
-
- /* wc tcam rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_WC_TCAM_ROW,
- tfs->TF_WC_TCAM_POOL_NAME_RX);
-
- /* wc tcam tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_WC_TCAM_ROW,
- tfs->TF_WC_TCAM_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the meter resources allocated that
- * Truflow does not own.
- */
-static void
-tf_rm_rsvd_meter(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_HW_METER_PROF;
- uint32_t end = 0;
-
- /* meter profiles rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_METER_PROF,
- tfs->TF_METER_PROF_POOL_NAME_RX);
-
- /* meter profiles tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_METER_PROF,
- tfs->TF_METER_PROF_POOL_NAME_TX);
-
- index = TF_RESC_TYPE_HW_METER_INST;
-
- /* meter rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_METER,
- tfs->TF_METER_INST_POOL_NAME_RX);
-
- /* meter tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_METER,
- tfs->TF_METER_INST_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the mirror resources allocated that
- * Truflow does not own.
- */
-static void
-tf_rm_rsvd_mirror(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_HW_MIRROR;
- uint32_t end = 0;
-
- /* mirror rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_MIRROR,
- tfs->TF_MIRROR_POOL_NAME_RX);
-
- /* mirror tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_MIRROR,
- tfs->TF_MIRROR_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the upar resources allocated that
- * Truflow does not own.
- */
-static void
-tf_rm_rsvd_upar(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_HW_UPAR;
- uint32_t end = 0;
-
- /* upar rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_UPAR,
- tfs->TF_UPAR_POOL_NAME_RX);
-
- /* upar tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_UPAR,
- tfs->TF_UPAR_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the sp tcam resources allocated that
- * Truflow does not own.
- */
-static void
-tf_rm_rsvd_sp_tcam(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_HW_SP_TCAM;
- uint32_t end = 0;
-
- /* sp tcam rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_SP_TCAM,
- tfs->TF_SP_TCAM_POOL_NAME_RX);
-
- /* sp tcam tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_SP_TCAM,
- tfs->TF_SP_TCAM_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the l2 func resources allocated that
- * Truflow does not own.
- */
-static void
-tf_rm_rsvd_l2_func(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_HW_L2_FUNC;
- uint32_t end = 0;
-
- /* l2 func rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_L2_FUNC,
- tfs->TF_L2_FUNC_POOL_NAME_RX);
-
- /* l2 func tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_L2_FUNC,
- tfs->TF_L2_FUNC_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the fkb resources allocated that
- * Truflow does not own.
- */
-static void
-tf_rm_rsvd_fkb(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_HW_FKB;
- uint32_t end = 0;
-
- /* fkb rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_FKB,
- tfs->TF_FKB_POOL_NAME_RX);
-
- /* fkb tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_FKB,
- tfs->TF_FKB_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the tbld scope resources allocated
- * that Truflow does not own.
- */
-static void
-tf_rm_rsvd_tbl_scope(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_HW_TBL_SCOPE;
- uint32_t end = 0;
-
- /* tbl scope rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_TBL_SCOPE,
- tfs->TF_TBL_SCOPE_POOL_NAME_RX);
-
- /* tbl scope tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_TBL_SCOPE,
- tfs->TF_TBL_SCOPE_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the l2 epoch resources allocated that
- * Truflow does not own.
- */
-static void
-tf_rm_rsvd_epoch(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_HW_EPOCH0;
- uint32_t end = 0;
-
- /* epoch0 rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_EPOCH0,
- tfs->TF_EPOCH0_POOL_NAME_RX);
-
- /* epoch0 tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_EPOCH0,
- tfs->TF_EPOCH0_POOL_NAME_TX);
-
- index = TF_RESC_TYPE_HW_EPOCH1;
-
- /* epoch1 rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_EPOCH1,
- tfs->TF_EPOCH1_POOL_NAME_RX);
-
- /* epoch1 tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_EPOCH1,
- tfs->TF_EPOCH1_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the metadata resources allocated that
- * Truflow does not own.
- */
-static void
-tf_rm_rsvd_metadata(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_HW_METADATA;
- uint32_t end = 0;
-
- /* metadata rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_METADATA,
- tfs->TF_METADATA_POOL_NAME_RX);
-
- /* metadata tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_METADATA,
- tfs->TF_METADATA_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the ct state resources allocated that
- * Truflow does not own.
- */
-static void
-tf_rm_rsvd_ct_state(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_HW_CT_STATE;
- uint32_t end = 0;
-
- /* ct state rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_CT_STATE,
- tfs->TF_CT_STATE_POOL_NAME_RX);
-
- /* ct state tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_CT_STATE,
- tfs->TF_CT_STATE_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the range resources allocated that
- * Truflow does not own.
- */
-static void
-tf_rm_rsvd_range(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_HW_RANGE_PROF;
- uint32_t end = 0;
-
- /* range profile rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_RANGE_PROF,
- tfs->TF_RANGE_PROF_POOL_NAME_RX);
-
- /* range profile tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_RANGE_PROF,
- tfs->TF_RANGE_PROF_POOL_NAME_TX);
-
- index = TF_RESC_TYPE_HW_RANGE_ENTRY;
-
- /* range entry rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_RANGE_ENTRY,
- tfs->TF_RANGE_ENTRY_POOL_NAME_RX);
-
- /* range entry tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_RANGE_ENTRY,
- tfs->TF_RANGE_ENTRY_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the lag resources allocated that
- * Truflow does not own.
- */
-static void
-tf_rm_rsvd_lag_entry(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_HW_LAG_ENTRY;
- uint32_t end = 0;
-
- /* lag entry rx direction */
- if (tfs->resc.rx.hw_entry[index].stride > 0)
- end = tfs->resc.rx.hw_entry[index].start +
- tfs->resc.rx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.hw_entry[index].stride,
- tfs->resc.rx.hw_entry[index].start,
- end,
- TF_NUM_LAG_ENTRY,
- tfs->TF_LAG_ENTRY_POOL_NAME_RX);
-
- /* lag entry tx direction */
- if (tfs->resc.tx.hw_entry[index].stride > 0)
- end = tfs->resc.tx.hw_entry[index].start +
- tfs->resc.tx.hw_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.hw_entry[index].stride,
- tfs->resc.tx.hw_entry[index].start,
- end,
- TF_NUM_LAG_ENTRY,
- tfs->TF_LAG_ENTRY_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the full action resources allocated
- * that Truflow does not own.
- */
-static void
-tf_rm_rsvd_sram_full_action(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_SRAM_FULL_ACTION;
- uint16_t end = 0;
-
- /* full action rx direction */
- if (tfs->resc.rx.sram_entry[index].stride > 0)
- end = tfs->resc.rx.sram_entry[index].start +
- tfs->resc.rx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.sram_entry[index].stride,
- TF_RSVD_SRAM_FULL_ACTION_BEGIN_IDX_RX,
- end,
- TF_RSVD_SRAM_FULL_ACTION_RX,
- tfs->TF_SRAM_FULL_ACTION_POOL_NAME_RX);
-
- /* full action tx direction */
- if (tfs->resc.tx.sram_entry[index].stride > 0)
- end = tfs->resc.tx.sram_entry[index].start +
- tfs->resc.tx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.sram_entry[index].stride,
- TF_RSVD_SRAM_FULL_ACTION_BEGIN_IDX_TX,
- end,
- TF_RSVD_SRAM_FULL_ACTION_TX,
- tfs->TF_SRAM_FULL_ACTION_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the multicast group resources
- * allocated that Truflow does not own.
- */
-static void
-tf_rm_rsvd_sram_mcg(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_SRAM_MCG;
- uint16_t end = 0;
-
- /* multicast group rx direction */
- if (tfs->resc.rx.sram_entry[index].stride > 0)
- end = tfs->resc.rx.sram_entry[index].start +
- tfs->resc.rx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.sram_entry[index].stride,
- TF_RSVD_SRAM_MCG_BEGIN_IDX_RX,
- end,
- TF_RSVD_SRAM_MCG_RX,
- tfs->TF_SRAM_MCG_POOL_NAME_RX);
-
- /* Multicast Group on TX is not supported */
-}
-
-/**
- * Internal function to mark all the encap resources allocated that
- * Truflow does not own.
- */
-static void
-tf_rm_rsvd_sram_encap(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_SRAM_ENCAP_8B;
- uint16_t end = 0;
-
- /* encap 8b rx direction */
- if (tfs->resc.rx.sram_entry[index].stride > 0)
- end = tfs->resc.rx.sram_entry[index].start +
- tfs->resc.rx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.sram_entry[index].stride,
- TF_RSVD_SRAM_ENCAP_8B_BEGIN_IDX_RX,
- end,
- TF_RSVD_SRAM_ENCAP_8B_RX,
- tfs->TF_SRAM_ENCAP_8B_POOL_NAME_RX);
-
- /* encap 8b tx direction */
- if (tfs->resc.tx.sram_entry[index].stride > 0)
- end = tfs->resc.tx.sram_entry[index].start +
- tfs->resc.tx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.sram_entry[index].stride,
- TF_RSVD_SRAM_ENCAP_8B_BEGIN_IDX_TX,
- end,
- TF_RSVD_SRAM_ENCAP_8B_TX,
- tfs->TF_SRAM_ENCAP_8B_POOL_NAME_TX);
-
- index = TF_RESC_TYPE_SRAM_ENCAP_16B;
-
- /* encap 16b rx direction */
- if (tfs->resc.rx.sram_entry[index].stride > 0)
- end = tfs->resc.rx.sram_entry[index].start +
- tfs->resc.rx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.sram_entry[index].stride,
- TF_RSVD_SRAM_ENCAP_16B_BEGIN_IDX_RX,
- end,
- TF_RSVD_SRAM_ENCAP_16B_RX,
- tfs->TF_SRAM_ENCAP_16B_POOL_NAME_RX);
-
- /* encap 16b tx direction */
- if (tfs->resc.tx.sram_entry[index].stride > 0)
- end = tfs->resc.tx.sram_entry[index].start +
- tfs->resc.tx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.sram_entry[index].stride,
- TF_RSVD_SRAM_ENCAP_16B_BEGIN_IDX_TX,
- end,
- TF_RSVD_SRAM_ENCAP_16B_TX,
- tfs->TF_SRAM_ENCAP_16B_POOL_NAME_TX);
-
- index = TF_RESC_TYPE_SRAM_ENCAP_64B;
-
- /* Encap 64B not supported on RX */
-
- /* Encap 64b tx direction */
- if (tfs->resc.tx.sram_entry[index].stride > 0)
- end = tfs->resc.tx.sram_entry[index].start +
- tfs->resc.tx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.sram_entry[index].stride,
- TF_RSVD_SRAM_ENCAP_64B_BEGIN_IDX_TX,
- end,
- TF_RSVD_SRAM_ENCAP_64B_TX,
- tfs->TF_SRAM_ENCAP_64B_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the sp resources allocated that
- * Truflow does not own.
- */
-static void
-tf_rm_rsvd_sram_sp(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_SRAM_SP_SMAC;
- uint16_t end = 0;
-
- /* sp smac rx direction */
- if (tfs->resc.rx.sram_entry[index].stride > 0)
- end = tfs->resc.rx.sram_entry[index].start +
- tfs->resc.rx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.sram_entry[index].stride,
- TF_RSVD_SRAM_SP_SMAC_BEGIN_IDX_RX,
- end,
- TF_RSVD_SRAM_SP_SMAC_RX,
- tfs->TF_SRAM_SP_SMAC_POOL_NAME_RX);
-
- /* sp smac tx direction */
- if (tfs->resc.tx.sram_entry[index].stride > 0)
- end = tfs->resc.tx.sram_entry[index].start +
- tfs->resc.tx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.sram_entry[index].stride,
- TF_RSVD_SRAM_SP_SMAC_BEGIN_IDX_TX,
- end,
- TF_RSVD_SRAM_SP_SMAC_TX,
- tfs->TF_SRAM_SP_SMAC_POOL_NAME_TX);
-
- index = TF_RESC_TYPE_SRAM_SP_SMAC_IPV4;
-
- /* SP SMAC IPv4 not supported on RX */
-
- /* sp smac ipv4 tx direction */
- if (tfs->resc.tx.sram_entry[index].stride > 0)
- end = tfs->resc.tx.sram_entry[index].start +
- tfs->resc.tx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.sram_entry[index].stride,
- TF_RSVD_SRAM_SP_SMAC_IPV4_BEGIN_IDX_TX,
- end,
- TF_RSVD_SRAM_SP_SMAC_IPV4_TX,
- tfs->TF_SRAM_SP_SMAC_IPV4_POOL_NAME_TX);
-
- index = TF_RESC_TYPE_SRAM_SP_SMAC_IPV6;
-
- /* SP SMAC IPv6 not supported on RX */
-
- /* sp smac ipv6 tx direction */
- if (tfs->resc.tx.sram_entry[index].stride > 0)
- end = tfs->resc.tx.sram_entry[index].start +
- tfs->resc.tx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.sram_entry[index].stride,
- TF_RSVD_SRAM_SP_SMAC_IPV6_BEGIN_IDX_TX,
- end,
- TF_RSVD_SRAM_SP_SMAC_IPV6_TX,
- tfs->TF_SRAM_SP_SMAC_IPV6_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the stat resources allocated that
- * Truflow does not own.
- */
-static void
-tf_rm_rsvd_sram_stats(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_SRAM_COUNTER_64B;
- uint16_t end = 0;
-
- /* counter 64b rx direction */
- if (tfs->resc.rx.sram_entry[index].stride > 0)
- end = tfs->resc.rx.sram_entry[index].start +
- tfs->resc.rx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.sram_entry[index].stride,
- TF_RSVD_SRAM_COUNTER_64B_BEGIN_IDX_RX,
- end,
- TF_RSVD_SRAM_COUNTER_64B_RX,
- tfs->TF_SRAM_STATS_64B_POOL_NAME_RX);
-
- /* counter 64b tx direction */
- if (tfs->resc.tx.sram_entry[index].stride > 0)
- end = tfs->resc.tx.sram_entry[index].start +
- tfs->resc.tx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.sram_entry[index].stride,
- TF_RSVD_SRAM_COUNTER_64B_BEGIN_IDX_TX,
- end,
- TF_RSVD_SRAM_COUNTER_64B_TX,
- tfs->TF_SRAM_STATS_64B_POOL_NAME_TX);
-}
-
-/**
- * Internal function to mark all the nat resources allocated that
- * Truflow does not own.
- */
-static void
-tf_rm_rsvd_sram_nat(struct tf_session *tfs)
-{
- uint32_t index = TF_RESC_TYPE_SRAM_NAT_SPORT;
- uint16_t end = 0;
-
- /* nat source port rx direction */
- if (tfs->resc.rx.sram_entry[index].stride > 0)
- end = tfs->resc.rx.sram_entry[index].start +
- tfs->resc.rx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.sram_entry[index].stride,
- TF_RSVD_SRAM_NAT_SPORT_BEGIN_IDX_RX,
- end,
- TF_RSVD_SRAM_NAT_SPORT_RX,
- tfs->TF_SRAM_NAT_SPORT_POOL_NAME_RX);
-
- /* nat source port tx direction */
- if (tfs->resc.tx.sram_entry[index].stride > 0)
- end = tfs->resc.tx.sram_entry[index].start +
- tfs->resc.tx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.sram_entry[index].stride,
- TF_RSVD_SRAM_NAT_SPORT_BEGIN_IDX_TX,
- end,
- TF_RSVD_SRAM_NAT_SPORT_TX,
- tfs->TF_SRAM_NAT_SPORT_POOL_NAME_TX);
-
- index = TF_RESC_TYPE_SRAM_NAT_DPORT;
-
- /* nat destination port rx direction */
- if (tfs->resc.rx.sram_entry[index].stride > 0)
- end = tfs->resc.rx.sram_entry[index].start +
- tfs->resc.rx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.sram_entry[index].stride,
- TF_RSVD_SRAM_NAT_DPORT_BEGIN_IDX_RX,
- end,
- TF_RSVD_SRAM_NAT_DPORT_RX,
- tfs->TF_SRAM_NAT_DPORT_POOL_NAME_RX);
-
- /* nat destination port tx direction */
- if (tfs->resc.tx.sram_entry[index].stride > 0)
- end = tfs->resc.tx.sram_entry[index].start +
- tfs->resc.tx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.sram_entry[index].stride,
- TF_RSVD_SRAM_NAT_DPORT_BEGIN_IDX_TX,
- end,
- TF_RSVD_SRAM_NAT_DPORT_TX,
- tfs->TF_SRAM_NAT_DPORT_POOL_NAME_TX);
-
- index = TF_RESC_TYPE_SRAM_NAT_S_IPV4;
-
- /* nat source port ipv4 rx direction */
- if (tfs->resc.rx.sram_entry[index].stride > 0)
- end = tfs->resc.rx.sram_entry[index].start +
- tfs->resc.rx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.sram_entry[index].stride,
- TF_RSVD_SRAM_NAT_S_IPV4_BEGIN_IDX_RX,
- end,
- TF_RSVD_SRAM_NAT_S_IPV4_RX,
- tfs->TF_SRAM_NAT_S_IPV4_POOL_NAME_RX);
-
- /* nat source ipv4 port tx direction */
- if (tfs->resc.tx.sram_entry[index].stride > 0)
- end = tfs->resc.tx.sram_entry[index].start +
- tfs->resc.tx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.sram_entry[index].stride,
- TF_RSVD_SRAM_NAT_S_IPV4_BEGIN_IDX_TX,
- end,
- TF_RSVD_SRAM_NAT_S_IPV4_TX,
- tfs->TF_SRAM_NAT_S_IPV4_POOL_NAME_TX);
-
- index = TF_RESC_TYPE_SRAM_NAT_D_IPV4;
-
- /* nat destination port ipv4 rx direction */
- if (tfs->resc.rx.sram_entry[index].stride > 0)
- end = tfs->resc.rx.sram_entry[index].start +
- tfs->resc.rx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.rx.sram_entry[index].stride,
- TF_RSVD_SRAM_NAT_D_IPV4_BEGIN_IDX_RX,
- end,
- TF_RSVD_SRAM_NAT_D_IPV4_RX,
- tfs->TF_SRAM_NAT_D_IPV4_POOL_NAME_RX);
-
- /* nat destination ipv4 port tx direction */
- if (tfs->resc.tx.sram_entry[index].stride > 0)
- end = tfs->resc.tx.sram_entry[index].start +
- tfs->resc.tx.sram_entry[index].stride - 1;
-
- tf_rm_reserve_range(tfs->resc.tx.sram_entry[index].stride,
- TF_RSVD_SRAM_NAT_D_IPV4_BEGIN_IDX_TX,
- end,
- TF_RSVD_SRAM_NAT_D_IPV4_TX,
- tfs->TF_SRAM_NAT_D_IPV4_POOL_NAME_TX);
-}
-
-/**
- * Internal function used to validate the HW allocated resources
- * against the requested values.
- */
-static int
-tf_rm_hw_alloc_validate(enum tf_dir dir,
- struct tf_rm_hw_alloc *hw_alloc,
- struct tf_rm_entry *hw_entry)
-{
- int error = 0;
- int i;
-
- for (i = 0; i < TF_RESC_TYPE_HW_MAX; i++) {
- if (hw_entry[i].stride != hw_alloc->hw_num[i]) {
- PMD_DRV_LOG(ERR,
- "%s, Alloc failed id:%d expect:%d got:%d\n",
- tf_dir_2_str(dir),
- i,
- hw_alloc->hw_num[i],
- hw_entry[i].stride);
- error = -1;
- }
- }
-
- return error;
-}
-
-/**
- * Internal function used to validate the SRAM allocated resources
- * against the requested values.
- */
-static int
-tf_rm_sram_alloc_validate(enum tf_dir dir __rte_unused,
- struct tf_rm_sram_alloc *sram_alloc,
- struct tf_rm_entry *sram_entry)
-{
- int error = 0;