src/dpdk/drivers/net/bnxt/tf_ulp/ulp_mapper.c
static int32_t
ulp_mapper_resource_index_tbl_alloc(struct bnxt_ulp_context *ulp_ctx,
				    struct bnxt_ulp_mapper_data *mapper_data,
				    struct bnxt_ulp_glb_resource_info *glb_res)
{
	struct tf_alloc_tbl_entry_parms	aparms = { 0 };
	struct tf_free_tbl_entry_parms	free_parms = { 0 };
	uint64_t regval;
	struct tf *tfp;
	uint32_t tbl_scope_id;
	int32_t rc = 0;

	tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx);
	if (!tfp)
		return -EINVAL;

	/* Get the scope id */
	rc = bnxt_ulp_cntxt_tbl_scope_id_get(ulp_ctx, &tbl_scope_id);
	if (rc) {
		BNXT_TF_DBG(ERR, "Failed to get table scope rc=%d\n", rc);
		return rc;
	}

	aparms.type = glb_res->resource_type;
	aparms.dir = glb_res->direction;
	aparms.search_enable = BNXT_ULP_SEARCH_BEFORE_ALLOC_NO;
	aparms.tbl_scope_id = tbl_scope_id;

	/* Allocate the index tbl using tf api */
	rc = tf_alloc_tbl_entry(tfp, &aparms);
	if (rc) {
		BNXT_TF_DBG(ERR, "Failed to alloc identifier [%s][%d]\n",
			    (aparms.dir == TF_DIR_RX) ? "RX" : "TX",
			    aparms.type);
		return rc;
	}

	/* entries are stored as big-endian format */
	regval = tfp_cpu_to_be_64((uint64_t)aparms.idx);
	/* write to the mapper global resource */
	rc = ulp_mapper_glb_resource_write(mapper_data, glb_res, regval);
	if (rc) {
		BNXT_TF_DBG(ERR, "Failed to write to global resource id\n");
		/* Free the identifier when update failed */
		free_parms.dir = aparms.dir;
		free_parms.type = aparms.type;
		free_parms.idx = aparms.idx;
		tf_free_tbl_entry(tfp, &free_parms);
		return rc;
	}
	return rc;
}
/*
 * Internal function to allocate index tbl resource and store it in mapper data.
 *
 * returns 0 on success
 */
Internal function to allocate index tbl resource and store it in mapper data.
returns 0 on success
Internal function to allocate index tbl resource and store it in mapper data . returns 0 on success
static int32_t
ulp_mapper_resource_index_tbl_alloc(struct bnxt_ulp_context *ulp_ctx,
				    struct bnxt_ulp_mapper_data *mapper_data,
				    struct bnxt_ulp_glb_resource_info *glb_res)
{
	struct tf_alloc_tbl_entry_parms	aparms = { 0 };
	struct tf_free_tbl_entry_parms	free_parms = { 0 };
	uint64_t regval;
	struct tf *tfp;
	uint32_t tbl_scope_id;
	int32_t rc = 0;
	tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx);
	if (!tfp)
		return -EINVAL;
	rc = bnxt_ulp_cntxt_tbl_scope_id_get(ulp_ctx, &tbl_scope_id);
	if (rc) {
		BNXT_TF_DBG(ERR, "Failed to get table scope rc=%d\n", rc);
		return rc;
	}
	aparms.type = glb_res->resource_type;
	aparms.dir = glb_res->direction;
	aparms.search_enable = BNXT_ULP_SEARCH_BEFORE_ALLOC_NO;
	aparms.tbl_scope_id = tbl_scope_id;
	rc = tf_alloc_tbl_entry(tfp, &aparms);
	if (rc) {
		BNXT_TF_DBG(ERR, "Failed to alloc identifier [%s][%d]\n",
			    (aparms.dir == TF_DIR_RX) ? "RX" : "TX",
			    aparms.type);
		return rc;
	}
	regval = tfp_cpu_to_be_64((uint64_t)aparms.idx);
	rc = ulp_mapper_glb_resource_write(mapper_data, glb_res, regval);
	if (rc) {
		BNXT_TF_DBG(ERR, "Failed to write to global resource id\n");
		free_parms.dir = aparms.dir;
		free_parms.type = aparms.type;
		free_parms.idx = aparms.idx;
		tf_free_tbl_entry(tfp, &free_parms);
		return rc;
	}
	return rc;
}
static int32_t ulp_mapper_resource_index_tbl_alloc ( struct bnxt_ulp_context * ulp_ctx , struct bnxt_ulp_mapper_data * mapper_data , struct bnxt_ulp_glb_resource_info * glb_res ) { struct tf_alloc_tbl_entry_parms aparms = { 0 } ; struct tf_free_tbl_entry_parms free_parms = { 0 } ; uint64_t regval ; struct tf * tfp ; uint32_t tbl_scope_id ; int32_t rc = 0 ; tfp = bnxt_ulp_cntxt_tfp_get ( ulp_ctx ) ; if ( ! tfp ) return - EINVAL ; rc = bnxt_ulp_cntxt_tbl_scope_id_get ( ulp_ctx , & tbl_scope_id ) ; if ( rc ) { BNXT_TF_DBG ( ERR , " \n " , rc ) ; return rc ; } aparms . type = glb_res -> resource_type ; aparms . dir = glb_res -> direction ; aparms . search_enable = BNXT_ULP_SEARCH_BEFORE_ALLOC_NO ; aparms . tbl_scope_id = tbl_scope_id ; rc = tf_alloc_tbl_entry ( tfp , & aparms ) ; if ( rc ) { BNXT_TF_DBG ( ERR , " \n " , ( aparms . dir == TF_DIR_RX ) ? " " : " " , aparms . type ) ; return rc ; } regval = tfp_cpu_to_be_64 ( ( uint64_t ) aparms . idx ) ; rc = ulp_mapper_glb_resource_write ( mapper_data , glb_res , regval ) ; if ( rc ) { BNXT_TF_DBG ( ERR , " \n " ) ; free_parms . dir = aparms . dir ; free_parms . type = aparms . type ; free_parms . idx = aparms . idx ; tf_free_tbl_entry ( tfp , & free_parms ) ; return rc ; } return rc ; }
Internal function to allocate index tbl resource and store it in mapper data.
Internal function to allocate index tbl resource and store it in mapper data .
/* Get the scope id */ /* Allocate the index tbl using tf api */ /* entries are stored as big-endian format */ /* write to the mapper global resource */ /* Free the identifier when update failed */