src/dpdk/drivers/net/bnxt/tf_ulp/ulp_mapper.c
static int32_t
ulp_mapper_ident_process(struct bnxt_ulp_mapper_parms *parms,
			 struct bnxt_ulp_mapper_tbl_info *tbl,
			 struct bnxt_ulp_mapper_ident_info *ident,
			 uint16_t *val)
{
	struct ulp_flow_db_res_params	fid_parms;
	uint64_t id = 0;
	int32_t idx;
	struct tf_alloc_identifier_parms iparms = { 0 };
	struct tf_free_identifier_parms free_parms = { 0 };
	struct tf *tfp;
	int rc;

	tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx);
	if (!tfp) {
		BNXT_TF_DBG(ERR, "Failed to get tf pointer\n");
		return -EINVAL;
	}

	idx = ident->regfile_idx;

	iparms.ident_type = ident->ident_type;
	iparms.dir = tbl->direction;

	rc = tf_alloc_identifier(tfp, &iparms);
	if (rc) {
		BNXT_TF_DBG(ERR, "Alloc ident %s:%d failed.\n",
			    (iparms.dir == TF_DIR_RX) ? "RX" : "TX",
			    iparms.ident_type);
		return rc;
	}

	id = (uint64_t)tfp_cpu_to_be_64(iparms.id);
	if (!ulp_regfile_write(parms->regfile, idx, id)) {
		BNXT_TF_DBG(ERR, "Regfile[%d] write failed.\n", idx);
		rc = -EINVAL;
		/* Need to free the identifier, so goto error */
		goto error;
	}

	/* Link the resource to the flow in the flow db */
	if (!val) {
		memset(&fid_parms, 0, sizeof(fid_parms));
		fid_parms.direction		= tbl->direction;
		fid_parms.resource_func	= ident->resource_func;
		fid_parms.resource_type	= ident->ident_type;
		fid_parms.resource_hndl	= iparms.id;
		fid_parms.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO;

		rc = ulp_flow_db_resource_add(parms->ulp_ctx,
					      parms->flow_type,
					      parms->fid,
					      &fid_parms);
		if (rc) {
			BNXT_TF_DBG(ERR, "Failed to link res to flow rc = %d\n",
				    rc);
			/* Need to free the identifier, so goto error */
			goto error;
		}
	} else {
		*val = iparms.id;
	}

	return 0;

error:
	/* Need to free the identifier */
	free_parms.dir		= tbl->direction;
	free_parms.ident_type	= ident->ident_type;
	free_parms.id		= iparms.id;

	(void)tf_free_identifier(tfp, &free_parms);

	BNXT_TF_DBG(ERR, "Ident process failed for %s:%s\n",
		    ident->description,
		    (tbl->direction == TF_DIR_RX) ? "RX" : "TX");
	return rc;
}
/*
 * Process the identifier instruction and either store it in the flow database
 * or return it in the val (if not NULL) on success.  If val is NULL, the
 * identifier is to be stored in the flow database.
 */
Process the identifier instruction and either store it in the flow database
or return it in the val (if not NULL) on success.  If val is NULL, the
identifier is to be stored in the flow database.
Process the identifier instruction and either store it in the flow database or return it in the val ( if not NULL ) on success . If val is NULL the identifier is to be stored in the flow database .
static int32_t
ulp_mapper_ident_process(struct bnxt_ulp_mapper_parms *parms,
			 struct bnxt_ulp_mapper_tbl_info *tbl,
			 struct bnxt_ulp_mapper_ident_info *ident,
			 uint16_t *val)
{
	struct ulp_flow_db_res_params	fid_parms;
	uint64_t id = 0;
	int32_t idx;
	struct tf_alloc_identifier_parms iparms = { 0 };
	struct tf_free_identifier_parms free_parms = { 0 };
	struct tf *tfp;
	int rc;
	tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx);
	if (!tfp) {
		BNXT_TF_DBG(ERR, "Failed to get tf pointer\n");
		return -EINVAL;
	}
	idx = ident->regfile_idx;
	iparms.ident_type = ident->ident_type;
	iparms.dir = tbl->direction;
	rc = tf_alloc_identifier(tfp, &iparms);
	if (rc) {
		BNXT_TF_DBG(ERR, "Alloc ident %s:%d failed.\n",
			    (iparms.dir == TF_DIR_RX) ? "RX" : "TX",
			    iparms.ident_type);
		return rc;
	}
	id = (uint64_t)tfp_cpu_to_be_64(iparms.id);
	if (!ulp_regfile_write(parms->regfile, idx, id)) {
		BNXT_TF_DBG(ERR, "Regfile[%d] write failed.\n", idx);
		rc = -EINVAL;
		goto error;
	}
	if (!val) {
		memset(&fid_parms, 0, sizeof(fid_parms));
		fid_parms.direction		= tbl->direction;
		fid_parms.resource_func	= ident->resource_func;
		fid_parms.resource_type	= ident->ident_type;
		fid_parms.resource_hndl	= iparms.id;
		fid_parms.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO;
		rc = ulp_flow_db_resource_add(parms->ulp_ctx,
					      parms->flow_type,
					      parms->fid,
					      &fid_parms);
		if (rc) {
			BNXT_TF_DBG(ERR, "Failed to link res to flow rc = %d\n",
				    rc);
			goto error;
		}
	} else {
		*val = iparms.id;
	}
	return 0;
error:
	free_parms.dir		= tbl->direction;
	free_parms.ident_type	= ident->ident_type;
	free_parms.id		= iparms.id;
	(void)tf_free_identifier(tfp, &free_parms);
	BNXT_TF_DBG(ERR, "Ident process failed for %s:%s\n",
		    ident->description,
		    (tbl->direction == TF_DIR_RX) ? "RX" : "TX");
	return rc;
}
static int32_t ulp_mapper_ident_process ( struct bnxt_ulp_mapper_parms * parms , struct bnxt_ulp_mapper_tbl_info * tbl , struct bnxt_ulp_mapper_ident_info * ident , uint16_t * val ) { struct ulp_flow_db_res_params fid_parms ; uint64_t id = 0 ; int32_t idx ; struct tf_alloc_identifier_parms iparms = { 0 } ; struct tf_free_identifier_parms free_parms = { 0 } ; struct tf * tfp ; int rc ; tfp = bnxt_ulp_cntxt_tfp_get ( parms -> ulp_ctx ) ; if ( ! tfp ) { BNXT_TF_DBG ( ERR , " \n " ) ; return - EINVAL ; } idx = ident -> regfile_idx ; iparms . ident_type = ident -> ident_type ; iparms . dir = tbl -> direction ; rc = tf_alloc_identifier ( tfp , & iparms ) ; if ( rc ) { BNXT_TF_DBG ( ERR , " \n " , ( iparms . dir == TF_DIR_RX ) ? " " : " " , iparms . ident_type ) ; return rc ; } id = ( uint64_t ) tfp_cpu_to_be_64 ( iparms . id ) ; if ( ! ulp_regfile_write ( parms -> regfile , idx , id ) ) { BNXT_TF_DBG ( ERR , " \n " , idx ) ; rc = - EINVAL ; goto error ; } if ( ! val ) { memset ( & fid_parms , 0 , sizeof ( fid_parms ) ) ; fid_parms . direction = tbl -> direction ; fid_parms . resource_func = ident -> resource_func ; fid_parms . resource_type = ident -> ident_type ; fid_parms . resource_hndl = iparms . id ; fid_parms . critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO ; rc = ulp_flow_db_resource_add ( parms -> ulp_ctx , parms -> flow_type , parms -> fid , & fid_parms ) ; if ( rc ) { BNXT_TF_DBG ( ERR , " \n " , rc ) ; goto error ; } } else { * val = iparms . id ; } return 0 ; error : free_parms . dir = tbl -> direction ; free_parms . ident_type = ident -> ident_type ; free_parms . id = iparms . id ; ( void ) tf_free_identifier ( tfp , & free_parms ) ; BNXT_TF_DBG ( ERR , " \n " , ident -> description , ( tbl -> direction == TF_DIR_RX ) ? " " : " " ) ; return rc ; }
Process the identifier instruction and either store it in the flow database
 or return it in the val (if not NULL) on success.
Process the identifier instruction and either store it in the flow database or return it in the val ( if not NULL ) on success .
/* Need to free the identifier, so goto error */ /* Link the resource to the flow in the flow db */ /* Need to free the identifier, so goto error */ /* Need to free the identifier */