src/dpdk/drivers/net/bnxt/tf_ulp/ulp_utils.c
uint32_t
ulp_blob_push_encap(struct ulp_blob *blob,
		    uint8_t *data,
		    uint32_t datalen)
{
	uint8_t		*val = (uint8_t *)data;
	uint32_t	initial_size, write_size = datalen;
	uint32_t	size = 0;

	if (!blob || !data ||
	    datalen > (uint32_t)(blob->bitlen - blob->write_idx)) {
		BNXT_TF_DBG(ERR, "invalid argument\n");
		return 0;
	}

	initial_size = ULP_BYTE_2_BITS(sizeof(uint64_t)) -
	    (blob->write_idx % ULP_BYTE_2_BITS(sizeof(uint64_t)));
	while (write_size > 0) {
		if (initial_size && write_size > initial_size) {
			size = initial_size;
			initial_size = 0;
		} else if (initial_size && write_size <= initial_size) {
			size = write_size;
			initial_size = 0;
		} else if (write_size > ULP_BYTE_2_BITS(sizeof(uint64_t))) {
			size = ULP_BYTE_2_BITS(sizeof(uint64_t));
		} else {
			size = write_size;
		}
		if (!ulp_blob_push(blob, val, size)) {
			BNXT_TF_DBG(ERR, "push field failed\n");
			return 0;
		}
		val += ULP_BITS_2_BYTE(size);
		write_size -= size;
	}
	return datalen;
}
/*
 * Add encap data to the binary blob at the current offset.
 *
 * blob [in] The blob that data is added to.  The blob must
 * be initialized prior to pushing data.
 *
 * data [in] value to be added to the blob.
 *
 * datalen [in] The number of bits to be added to the blob.
 *
 * The offset of the data is updated after each push of data.
 * NULL returned on error, pointer pushed value otherwise.
 */
Add encap data to the binary blob at the current offset.
blob [in] The blob that data is added to.  The blob must
be initialized prior to pushing data.

data [in] value to be added to the blob.

datalen [in] The number of bits to be added to the blob.

The offset of the data is updated after each push of data.
NULL returned on error, pointer pushed value otherwise.
Add encap data to the binary blob at the current offset . blob [ in ] The blob that data is added to . The blob must be initialized prior to pushing data . data [ in ] value to be added to the blob . datalen [ in ] The number of bits to be added to the blob . The offset of the data is updated after each push of data . NULL returned on error pointer pushed value otherwise .
uint32_t
ulp_blob_push_encap(struct ulp_blob *blob,
		    uint8_t *data,
		    uint32_t datalen)
{
	uint8_t		*val = (uint8_t *)data;
	uint32_t	initial_size, write_size = datalen;
	uint32_t	size = 0;
	if (!blob || !data ||
	    datalen > (uint32_t)(blob->bitlen - blob->write_idx)) {
		BNXT_TF_DBG(ERR, "invalid argument\n");
		return 0;
	}
	initial_size = ULP_BYTE_2_BITS(sizeof(uint64_t)) -
	    (blob->write_idx % ULP_BYTE_2_BITS(sizeof(uint64_t)));
	while (write_size > 0) {
		if (initial_size && write_size > initial_size) {
			size = initial_size;
			initial_size = 0;
		} else if (initial_size && write_size <= initial_size) {
			size = write_size;
			initial_size = 0;
		} else if (write_size > ULP_BYTE_2_BITS(sizeof(uint64_t))) {
			size = ULP_BYTE_2_BITS(sizeof(uint64_t));
		} else {
			size = write_size;
		}
		if (!ulp_blob_push(blob, val, size)) {
			BNXT_TF_DBG(ERR, "push field failed\n");
			return 0;
		}
		val += ULP_BITS_2_BYTE(size);
		write_size -= size;
	}
	return datalen;
}
uint32_t ulp_blob_push_encap ( struct ulp_blob * blob , uint8_t * data , uint32_t datalen ) { uint8_t * val = ( uint8_t * ) data ; uint32_t initial_size , write_size = datalen ; uint32_t size = 0 ; if ( ! blob || ! data || datalen > ( uint32_t ) ( blob -> bitlen - blob -> write_idx ) ) { BNXT_TF_DBG ( ERR , " \n " ) ; return 0 ; } initial_size = ULP_BYTE_2_BITS ( sizeof ( uint64_t ) ) - ( blob -> write_idx % ULP_BYTE_2_BITS ( sizeof ( uint64_t ) ) ) ; while ( write_size > 0 ) { if ( initial_size && write_size > initial_size ) { size = initial_size ; initial_size = 0 ; } else if ( initial_size && write_size <= initial_size ) { size = write_size ; initial_size = 0 ; } else if ( write_size > ULP_BYTE_2_BITS ( sizeof ( uint64_t ) ) ) { size = ULP_BYTE_2_BITS ( sizeof ( uint64_t ) ) ; } else { size = write_size ; } if ( ! ulp_blob_push ( blob , val , size ) ) { BNXT_TF_DBG ( ERR , " \n " ) ; return 0 ; } val += ULP_BITS_2_BYTE ( size ) ; write_size -= size ; } return datalen ; }
Add encap data to the binary blob at the current offset.
Add encap data to the binary blob at the current offset .