src/dpdk/drivers/net/nfp/nfpcore/nfp_cppcore.c
struct nfp_cpp_area *
nfp_cpp_area_alloc_with_name(struct nfp_cpp *cpp, uint32_t dest,
			      const char *name, unsigned long long address,
			      unsigned long size)
{
	struct nfp_cpp_area *area;
	uint64_t tmp64 = (uint64_t)address;
	int tmp, err;

	if (!cpp)
		return NULL;

	/* CPP bus uses only a 40-bit address */
	if ((address + size) > (1ULL << 40))
		return NFP_ERRPTR(EFAULT);

	/* Remap from cpp_island to cpp_target */
	err = nfp_target_cpp(dest, tmp64, &dest, &tmp64, cpp->imb_cat_table);
	if (err < 0)
		return NULL;

	address = (unsigned long long)tmp64;

	if (!name)
		name = "";

	area = calloc(1, sizeof(*area) + cpp->op->area_priv_size +
		      strlen(name) + 1);
	if (!area)
		return NULL;

	area->cpp = cpp;
	area->name = ((char *)area) + sizeof(*area) + cpp->op->area_priv_size;
	memcpy(area->name, name, strlen(name) + 1);

	/*
	 * Preserve errno around the call to area_init, since most
	 * implementations will blindly call nfp_target_action_width()for both
	 * read or write modes, and that will set errno to EINVAL.
	 */
	tmp = errno;

	err = cpp->op->area_init(area, dest, address, size);
	if (err < 0) {
		free(area);
		return NULL;
	}

	/* Restore errno */
	errno = tmp;

	area->offset = address;
	area->size = size;

	return area;
}
/*
 * nfp_cpp_area_alloc - allocate a new CPP area
 * @cpp:    CPP handle
 * @dest:   CPP id
 * @address:    start address on CPP target
 * @size:   size of area in bytes
 *
 * Allocate and initialize a CPP area structure.  The area must later
 * be locked down with an 'acquire' before it can be safely accessed.
 *
 * NOTE: @address and @size must be 32-bit aligned values.
 */
allocate a new CPP area
@cpp:    CPP handle
@dest:   CPP id
@address:    start address on CPP target
@size:   size of area in bytes

Allocate and initialize a CPP area structure.  The area must later
be locked down with an 'acquire' before it can be safely accessed.

@address and @size must be 32-bit aligned values.
allocate a new CPP area @cpp : CPP handle @dest : CPP id @address : start address on CPP target @size : size of area in bytes Allocate and initialize a CPP area structure . The area must later be locked down with an ' acquire ' before it can be safely accessed . @address and @size must be 32 - bit aligned values .
struct nfp_cpp_area *
nfp_cpp_area_alloc_with_name(struct nfp_cpp *cpp, uint32_t dest,
			      const char *name, unsigned long long address,
			      unsigned long size)
{
	struct nfp_cpp_area *area;
	uint64_t tmp64 = (uint64_t)address;
	int tmp, err;
	if (!cpp)
		return NULL;
	if ((address + size) > (1ULL << 40))
		return NFP_ERRPTR(EFAULT);
	err = nfp_target_cpp(dest, tmp64, &dest, &tmp64, cpp->imb_cat_table);
	if (err < 0)
		return NULL;
	address = (unsigned long long)tmp64;
	if (!name)
		name = "";
	area = calloc(1, sizeof(*area) + cpp->op->area_priv_size +
		      strlen(name) + 1);
	if (!area)
		return NULL;
	area->cpp = cpp;
	area->name = ((char *)area) + sizeof(*area) + cpp->op->area_priv_size;
	memcpy(area->name, name, strlen(name) + 1);
	tmp = errno;
	err = cpp->op->area_init(area, dest, address, size);
	if (err < 0) {
		free(area);
		return NULL;
	}
	errno = tmp;
	area->offset = address;
	area->size = size;
	return area;
}
struct nfp_cpp_area * nfp_cpp_area_alloc_with_name ( struct nfp_cpp * cpp , uint32_t dest , const char * name , unsigned long long address , unsigned long size ) { struct nfp_cpp_area * area ; uint64_t tmp64 = ( uint64_t ) address ; int tmp , err ; if ( ! cpp ) return NULL ; if ( ( address + size ) > ( 1ULL << 40 ) ) return NFP_ERRPTR ( EFAULT ) ; err = nfp_target_cpp ( dest , tmp64 , & dest , & tmp64 , cpp -> imb_cat_table ) ; if ( err < 0 ) return NULL ; address = ( unsigned long long ) tmp64 ; if ( ! name ) name = " " ; area = calloc ( 1 , sizeof ( * area ) + cpp -> op -> area_priv_size + strlen ( name ) + 1 ) ; if ( ! area ) return NULL ; area -> cpp = cpp ; area -> name = ( ( char * ) area ) + sizeof ( * area ) + cpp -> op -> area_priv_size ; memcpy ( area -> name , name , strlen ( name ) + 1 ) ; tmp = errno ; err = cpp -> op -> area_init ( area , dest , address , size ) ; if ( err < 0 ) { free ( area ) ; return NULL ; } errno = tmp ; area -> offset = address ; area -> size = size ; return area ; }
nfp_cpp_area_alloc - allocate a new CPP area
 @cpp:    CPP handle
 @dest:   CPP id
 @address:    start address on CPP target
 @size:   size of area in bytes
nfp_cpp_area_alloc - allocate a new CPP area @cpp : CPP handle @dest : CPP id @address : start address on CPP target @size : size of area in bytes
/* CPP bus uses only a 40-bit address */ /* Remap from cpp_island to cpp_target */ /*
	 * Preserve errno around the call to area_init, since most
	 * implementations will blindly call nfp_target_action_width()for both
	 * read or write modes, and that will set errno to EINVAL.
	 */ /* Restore errno */