X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fbnxt%2Ftf_ulp%2Fulp_utils.h;h=749ac06d87614f67b4cc0586cbb5e0c41c40b75e;hb=fcf681890a31a7396df2b85b2888074c5b939535;hp=5db3933986ded8a65e1ec60ab170bb6b55577167;hpb=2bbcdee826ffd5dc4d05f4aaab88375832577fb4;p=dpdk.git diff --git a/drivers/net/bnxt/tf_ulp/ulp_utils.h b/drivers/net/bnxt/tf_ulp/ulp_utils.h index 5db3933986..749ac06d87 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_utils.h +++ b/drivers/net/bnxt/tf_ulp/ulp_utils.h @@ -7,8 +7,12 @@ #define _ULP_UTILS_H_ #include "bnxt.h" -#include "ulp_template_db.h" +#include "ulp_template_db_enum.h" +#define ULP_BUFFER_ALIGN_8_BYTE 8 +#define ULP_BUFFER_ALIGN_16_BYTE 16 +#define ULP_BUFFER_ALIGN_64_BYTE 64 +#define ULP_64B_IN_BYTES 8 /* * Macros for bitmap sets and gets * These macros can be used if the val are power of 2. @@ -50,11 +54,17 @@ /* Macro to convert bits to bytes with no round off*/ #define ULP_BITS_2_BYTE_NR(bits_x) ((bits_x) / 8) +/* Macro to round off to next multiple of 8*/ +#define ULP_BYTE_ROUND_OFF_8(x) (((x) + 7) & ~7) + +/* Macro to check bits are byte aligned */ +#define ULP_BITS_IS_BYTE_NOT_ALIGNED(x) ((x) % 8) + /* Macros to read the computed fields */ -#define ULP_UTIL_CHF_IDX_RD(params, idx) \ +#define ULP_COMP_FLD_IDX_RD(params, idx) \ rte_be_to_cpu_32((params)->comp_fld[(idx)]) -#define ULP_UTIL_CHF_IDX_WR(params, idx, val) \ +#define ULP_COMP_FLD_IDX_WR(params, idx, val) \ ((params)->comp_fld[(idx)] = rte_cpu_to_be_32((val))) /* * Making the blob statically sized to 128 bytes for now. @@ -160,6 +170,25 @@ ulp_blob_push(struct ulp_blob *blob, uint8_t *data, uint32_t datalen); +/* + * Insert data into the binary blob at the given offset. + * + * blob [in] The blob that data is added to. The blob must + * be initialized prior to pushing data. + * + * offset [in] The offset where the data needs to be inserted. + * + * data [in/out] A pointer to bytes 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. + */ +uint32_t +ulp_blob_insert(struct ulp_blob *blob, uint32_t offset, + uint8_t *data, uint32_t datalen); + /* * Add data to the binary blob at the current offset. * @@ -178,6 +207,24 @@ ulp_blob_push_64(struct ulp_blob *blob, uint64_t *data, uint32_t datalen); +/* + * Add 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] 32-bit value to be added to the blob. + * + * datalen [in] The number of bits to be added ot the blob. + * + * The offset of the data is updated after each push of data. + * NULL returned on error, pointer pushed value otherwise. + */ +uint8_t * +ulp_blob_push_32(struct ulp_blob *blob, + uint32_t *data, + uint32_t datalen); + /* * Add encap data to the binary blob at the current offset. * @@ -210,6 +257,23 @@ uint8_t * ulp_blob_data_get(struct ulp_blob *blob, uint16_t *datalen); +/* + * Extract data from the binary blob using given offset. + * + * blob [in] The blob that data is extracted from. The blob must + * be initialized prior to pulling data. + * + * data [in] A pointer to put the data. + * data_size [in] size of the data buffer in bytes. + *offset [in] - Offset in the blob to extract the data in bits format. + * len [in] The number of bits to be pulled from the blob. + * + * Output: zero on success, -1 on failure + */ +int32_t +ulp_blob_pull(struct ulp_blob *blob, uint8_t *data, uint32_t data_size, + uint16_t offset, uint16_t len); + /* * Adds pad to an initialized blob at the current offset * @@ -218,9 +282,9 @@ ulp_blob_data_get(struct ulp_blob *blob, * * datalen [in] The number of bits of pad to add * - * returns the number of pad bits added, zero on failure + * returns the number of pad bits added, -1 on failure */ -uint32_t +int32_t ulp_blob_pad_push(struct ulp_blob *blob, uint32_t datalen); @@ -245,6 +309,42 @@ ulp_blob_encap_swap_idx_set(struct ulp_blob *blob); void ulp_blob_perform_encap_swap(struct ulp_blob *blob); +/* + * Perform the blob buffer reversal byte wise. + * This api makes the first byte the last and + * vice-versa. + * + * blob [in] The blob's data to be used for swap. + * + * returns void. + */ +void +ulp_blob_perform_byte_reverse(struct ulp_blob *blob); + +/* + * Perform the blob buffer 64 bit word swap. + * This api makes the first 4 bytes the last in + * a given 64 bit value and vice-versa. + * + * blob [in] The blob's data to be used for swap. + * + * returns void. + */ +void +ulp_blob_perform_64B_word_swap(struct ulp_blob *blob); + +/* + * Perform the blob buffer 64 bit byte swap. + * This api makes the first byte the last in + * a given 64 bit value and vice-versa. + * + * blob [in] The blob's data to be used for swap. + * + * returns void. + */ +void +ulp_blob_perform_64B_byte_swap(struct ulp_blob *blob); + /* * Read data from the operand * @@ -268,11 +368,13 @@ ulp_operand_read(uint8_t *operand, * dst [out] The destination buffer * src [in] The source buffer dst * size[in] size of the buffer. + * align[in] The alignment is either 8 or 16. */ void ulp_encap_buffer_copy(uint8_t *dst, const uint8_t *src, - uint16_t size); + uint16_t size, + uint16_t align); /* * Check the buffer is empty