src/dpdk/drivers/net/bnxt/tf_core/tf_rm.c
static int
tf_rm_check_residuals(struct tf_rm_new_db *rm_db,
		      uint16_t *resv_size,
		      struct tf_rm_resc_entry **resv,
		      bool *residuals_present)
{
	int rc;
	int i;
	int f;
	uint16_t count;
	uint16_t found;
	uint16_t *residuals = NULL;
	uint16_t hcapi_type;
	struct tf_rm_get_inuse_count_parms iparms;
	struct tf_rm_get_alloc_info_parms aparms;
	struct tf_rm_get_hcapi_parms hparms;
	struct tf_rm_alloc_info info;
	struct tfp_calloc_parms cparms;
	struct tf_rm_resc_entry *local_resv = NULL;

	/* Create array to hold the entries that have residuals */
	cparms.nitems = rm_db->num_entries;
	cparms.size = sizeof(uint16_t);
	cparms.alignment = 0;
	rc = tfp_calloc(&cparms);
	if (rc)
		return rc;

	residuals = (uint16_t *)cparms.mem_va;

	/* Traverse the DB and collect any residual elements */
	iparms.rm_db = rm_db;
	iparms.count = &count;
	for (i = 0, found = 0; i < rm_db->num_entries; i++) {
		iparms.db_index = i;
		rc = tf_rm_get_inuse_count(&iparms);
		/* Not a device supported entry, just skip */
		if (rc == -ENOTSUP)
			continue;
		if (rc)
			goto cleanup_residuals;

		if (count) {
			found++;
			residuals[i] = count;
			*residuals_present = true;
		}
	}

	if (*residuals_present) {
		/* Populate a reduced resv array with only the entries
		 * that have residuals.
		 */
		cparms.nitems = found;
		cparms.size = sizeof(struct tf_rm_resc_entry);
		cparms.alignment = 0;
		rc = tfp_calloc(&cparms);
		if (rc)
			return rc;

		local_resv = (struct tf_rm_resc_entry *)cparms.mem_va;

		aparms.rm_db = rm_db;
		hparms.rm_db = rm_db;
		hparms.hcapi_type = &hcapi_type;
		for (i = 0, f = 0; i < rm_db->num_entries; i++) {
			if (residuals[i] == 0)
				continue;
			aparms.db_index = i;
			aparms.info = &info;
			rc = tf_rm_get_info(&aparms);
			if (rc)
				goto cleanup_all;

			hparms.db_index = i;
			rc = tf_rm_get_hcapi_type(&hparms);
			if (rc)
				goto cleanup_all;

			local_resv[f].type = hcapi_type;
			local_resv[f].start = info.entry.start;
			local_resv[f].stride = info.entry.stride;
			f++;
		}
		*resv_size = found;
	}

	tf_rm_log_residuals(rm_db->dir,
			    rm_db->type,
			    rm_db->num_entries,
			    residuals);

	tfp_free((void *)residuals);
	*resv = local_resv;

	return 0;

 cleanup_all:
	tfp_free((void *)local_resv);
	*resv = NULL;
 cleanup_residuals:
	tfp_free((void *)residuals);

	return rc;
}
/**
 * Performs a check of the passed in DB for any lingering elements. If
 * a resource type was found to not have been cleaned up by the caller
 * then its residual values are recorded, logged and passed back in an
 * allocate reservation array that the caller can pass to the FW for
 * cleanup.
 *
 * [in] db
 *   Pointer to the db, used for the lookup
 *
 * [out] resv_size
 *   Pointer to the reservation size of the generated reservation
 *   array.
 *
 * [in/out] resv
 *   Pointer Pointer to a reservation array. The reservation array is
 *   allocated after the residual scan and holds any found residual
 *   entries. Thus it can be smaller than the DB that the check was
 *   performed on. Array must be freed by the caller.
 *
 * [out] residuals_present
 *   Pointer to a bool flag indicating if residual was present in the
 *   DB
 *
 * Returns:
 *     0          - Success
 *   - EOPNOTSUPP - Operation not supported
 */
Performs a check of the passed in DB for any lingering elements. If
a resource type was found to not have been cleaned up by the caller
then its residual values are recorded, logged and passed back in an
allocate reservation array that the caller can pass to the FW for
cleanup.

[in] db
Pointer to the db, used for the lookup

[out] resv_size
Pointer to the reservation size of the generated reservation
array.

[in/out] resv
Pointer Pointer to a reservation array. The reservation array is
allocated after the residual scan and holds any found residual
entries. Thus it can be smaller than the DB that the check was
performed on. Array must be freed by the caller.

[out] residuals_present
Pointer to a bool flag indicating if residual was present in the
DB

0          - Success
- EOPNOTSUPP - Operation not supported
Performs a check of the passed in DB for any lingering elements . If a resource type was found to not have been cleaned up by the caller then its residual values are recorded logged and passed back in an allocate reservation array that the caller can pass to the FW for cleanup . [ in ] db Pointer to the db used for the lookup [ out ] resv_size Pointer to the reservation size of the generated reservation array . [ in / out ] resv Pointer Pointer to a reservation array . The reservation array is allocated after the residual scan and holds any found residual entries . Thus it can be smaller than the DB that the check was performed on . Array must be freed by the caller . [ out ] residuals_present Pointer to a bool flag indicating if residual was present in the DB 0 - Success - EOPNOTSUPP - Operation not supported
static int
tf_rm_check_residuals(struct tf_rm_new_db *rm_db,
		      uint16_t *resv_size,
		      struct tf_rm_resc_entry **resv,
		      bool *residuals_present)
{
	int rc;
	int i;
	int f;
	uint16_t count;
	uint16_t found;
	uint16_t *residuals = NULL;
	uint16_t hcapi_type;
	struct tf_rm_get_inuse_count_parms iparms;
	struct tf_rm_get_alloc_info_parms aparms;
	struct tf_rm_get_hcapi_parms hparms;
	struct tf_rm_alloc_info info;
	struct tfp_calloc_parms cparms;
	struct tf_rm_resc_entry *local_resv = NULL;
	cparms.nitems = rm_db->num_entries;
	cparms.size = sizeof(uint16_t);
	cparms.alignment = 0;
	rc = tfp_calloc(&cparms);
	if (rc)
		return rc;
	residuals = (uint16_t *)cparms.mem_va;
	iparms.rm_db = rm_db;
	iparms.count = &count;
	for (i = 0, found = 0; i < rm_db->num_entries; i++) {
		iparms.db_index = i;
		rc = tf_rm_get_inuse_count(&iparms);
		if (rc == -ENOTSUP)
			continue;
		if (rc)
			goto cleanup_residuals;
		if (count) {
			found++;
			residuals[i] = count;
			*residuals_present = true;
		}
	}
	if (*residuals_present) {
		cparms.nitems = found;
		cparms.size = sizeof(struct tf_rm_resc_entry);
		cparms.alignment = 0;
		rc = tfp_calloc(&cparms);
		if (rc)
			return rc;
		local_resv = (struct tf_rm_resc_entry *)cparms.mem_va;
		aparms.rm_db = rm_db;
		hparms.rm_db = rm_db;
		hparms.hcapi_type = &hcapi_type;
		for (i = 0, f = 0; i < rm_db->num_entries; i++) {
			if (residuals[i] == 0)
				continue;
			aparms.db_index = i;
			aparms.info = &info;
			rc = tf_rm_get_info(&aparms);
			if (rc)
				goto cleanup_all;
			hparms.db_index = i;
			rc = tf_rm_get_hcapi_type(&hparms);
			if (rc)
				goto cleanup_all;
			local_resv[f].type = hcapi_type;
			local_resv[f].start = info.entry.start;
			local_resv[f].stride = info.entry.stride;
			f++;
		}
		*resv_size = found;
	}
	tf_rm_log_residuals(rm_db->dir,
			    rm_db->type,
			    rm_db->num_entries,
			    residuals);
	tfp_free((void *)residuals);
	*resv = local_resv;
	return 0;
 cleanup_all:
	tfp_free((void *)local_resv);
	*resv = NULL;
 cleanup_residuals:
	tfp_free((void *)residuals);
	return rc;
}
static int tf_rm_check_residuals ( struct tf_rm_new_db * rm_db , uint16_t * resv_size , struct tf_rm_resc_entry * * resv , bool * residuals_present ) { int rc ; int i ; int f ; uint16_t count ; uint16_t found ; uint16_t * residuals = NULL ; uint16_t hcapi_type ; struct tf_rm_get_inuse_count_parms iparms ; struct tf_rm_get_alloc_info_parms aparms ; struct tf_rm_get_hcapi_parms hparms ; struct tf_rm_alloc_info info ; struct tfp_calloc_parms cparms ; struct tf_rm_resc_entry * local_resv = NULL ; cparms . nitems = rm_db -> num_entries ; cparms . size = sizeof ( uint16_t ) ; cparms . alignment = 0 ; rc = tfp_calloc ( & cparms ) ; if ( rc ) return rc ; residuals = ( uint16_t * ) cparms . mem_va ; iparms . rm_db = rm_db ; iparms . count = & count ; for ( i = 0 , found = 0 ; i < rm_db -> num_entries ; i ++ ) { iparms . db_index = i ; rc = tf_rm_get_inuse_count ( & iparms ) ; if ( rc == - ENOTSUP ) continue ; if ( rc ) goto cleanup_residuals ; if ( count ) { found ++ ; residuals [ i ] = count ; * residuals_present = true ; } } if ( * residuals_present ) { cparms . nitems = found ; cparms . size = sizeof ( struct tf_rm_resc_entry ) ; cparms . alignment = 0 ; rc = tfp_calloc ( & cparms ) ; if ( rc ) return rc ; local_resv = ( struct tf_rm_resc_entry * ) cparms . mem_va ; aparms . rm_db = rm_db ; hparms . rm_db = rm_db ; hparms . hcapi_type = & hcapi_type ; for ( i = 0 , f = 0 ; i < rm_db -> num_entries ; i ++ ) { if ( residuals [ i ] == 0 ) continue ; aparms . db_index = i ; aparms . info = & info ; rc = tf_rm_get_info ( & aparms ) ; if ( rc ) goto cleanup_all ; hparms . db_index = i ; rc = tf_rm_get_hcapi_type ( & hparms ) ; if ( rc ) goto cleanup_all ; local_resv [ f ] . type = hcapi_type ; local_resv [ f ] . start = info . entry . start ; local_resv [ f ] . stride = info . entry . stride ; f ++ ; } * resv_size = found ; } tf_rm_log_residuals ( rm_db -> dir , rm_db -> type , rm_db -> num_entries , residuals ) ; tfp_free ( ( void * ) residuals ) ; * resv = local_resv ; return 0 ; cleanup_all : tfp_free ( ( void * ) local_resv ) ; * resv = NULL ; cleanup_residuals : tfp_free ( ( void * ) residuals ) ; return rc ; }
Performs a check of the passed in DB for any lingering elements.
Performs a check of the passed in DB for any lingering elements .
/* Create array to hold the entries that have residuals */ /* Traverse the DB and collect any residual elements */ /* Not a device supported entry, just skip */ /* Populate a reduced resv array with only the entries
		 * that have residuals.
		 */