X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fbnxt%2Ftf_ulp%2Fulp_utils.c;h=df3afaa6fdef5359673dc919f745fc1741206bba;hb=c8834a3663b7ff3269a1b4e6a2772999dd485760;hp=1649e157f2a356e3520259961f288a5b94024ee3;hpb=ad9eed0248adc0347dd7038fe547f4cffb100764;p=dpdk.git diff --git a/drivers/net/bnxt/tf_ulp/ulp_utils.c b/drivers/net/bnxt/tf_ulp/ulp_utils.c index 1649e157f2..df3afaa6fd 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_utils.c +++ b/drivers/net/bnxt/tf_ulp/ulp_utils.c @@ -62,7 +62,7 @@ ulp_regfile_read(struct ulp_regfile *regfile, * data [in] The value is written into this variable. It is going to be in the * same byte order as it was written. * - * size [in] The size in bytes of the value beingritten into this + * size [in] The size in bytes of the value being written into this * variable. * * returns 0 on success @@ -295,7 +295,7 @@ ulp_blob_push(struct ulp_blob *blob, datalen, data); if (!rc) { - BNXT_TF_DBG(ERR, "Failed ro write blob\n"); + BNXT_TF_DBG(ERR, "Failed to write blob\n"); return 0; } blob->write_idx += datalen; @@ -355,7 +355,7 @@ ulp_blob_insert(struct ulp_blob *blob, uint32_t offset, datalen, data); if (!rc) { - BNXT_TF_DBG(ERR, "Failed ro write blob\n"); + BNXT_TF_DBG(ERR, "Failed to write blob\n"); return 0; } /* copy the previously stored data */ @@ -409,7 +409,7 @@ ulp_blob_push_64(struct ulp_blob *blob, * * data [in] 32-bit value to be added to the blob. * - * datalen [in] The number of bits to be added ot 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. @@ -882,7 +882,8 @@ ulp_blob_msb_block_merge(struct ulp_blob *dst, struct ulp_blob *src, for (i = 0; i < num;) { if (((dst->write_idx % block_size) + (num - i)) > block_size) - write_bytes = block_size - dst->write_idx; + write_bytes = block_size - + (dst->write_idx % block_size); else write_bytes = num - i; for (k = 0; k < ULP_BITS_2_BYTE_NR(write_bytes); k++) { @@ -964,8 +965,11 @@ ulp_blob_append(struct ulp_blob *dst, struct ulp_blob *src, ulp_bs_put_msb(dst->data, dst->write_idx, ULP_BLOB_BYTE, bluff); dst->write_idx += remaining; + src_offset += remaining; } + src_buf += ULP_BITS_2_BYTE_NR(src_offset); + /* Push the byte aligned pieces */ for (k = 0; k < ULP_BITS_2_BYTE_NR(src_len); k++) { ulp_bs_put_msb(dst->data, dst->write_idx, ULP_BLOB_BYTE, @@ -987,6 +991,33 @@ ulp_blob_append(struct ulp_blob *dst, struct ulp_blob *src, return 0; } +/* + * Perform the blob buffer copy. + * This api makes the src blob merged to the dst blob. + * + * dst [in] The destination blob, the blob to be merged. + * src [in] The src blob. + * + * returns 0 on success. + */ +int32_t +ulp_blob_buffer_copy(struct ulp_blob *dst, struct ulp_blob *src) +{ + if ((dst->write_idx + src->write_idx) > dst->bitlen) { + BNXT_TF_DBG(ERR, "source buffer too large\n"); + return -EINVAL; + } + if (ULP_BITS_IS_BYTE_NOT_ALIGNED(dst->write_idx) || + ULP_BITS_IS_BYTE_NOT_ALIGNED(src->write_idx)) { + BNXT_TF_DBG(ERR, "source buffer is not aligned\n"); + return -EINVAL; + } + memcpy(&dst->data[ULP_BITS_2_BYTE_NR(dst->write_idx)], + src->data, ULP_BITS_2_BYTE_NR(src->write_idx)); + dst->write_idx += src->write_idx; + return 0; +} + /* * Read data from the operand * @@ -1012,44 +1043,6 @@ ulp_operand_read(uint8_t *operand, return bytes; } -/* - * copy the buffer in the encap format which is 2 bytes. - * The MSB of the src is placed at the LSB of dst. - * - * 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 align) -{ - uint16_t idx, tmp_size = 0; - - do { - dst += tmp_size; - src += tmp_size; - idx = 0; - if (size > align) { - tmp_size = align; - size -= align; - } else { - tmp_size = size; - size = 0; - } - /* copy 2 bytes at a time. Write MSB to LSB */ - while ((idx + sizeof(uint16_t)) <= tmp_size) { - memcpy(&dst[idx], - &src[tmp_size - idx - sizeof(uint16_t)], - sizeof(uint16_t)); - idx += sizeof(uint16_t); - } - } while (size); -} - /* * Check the buffer is empty *