From: Somnath Kotur <somnath.kotur@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com
Subject: [dpdk-dev] [PATCH 05/10] net/bnxt: add support to extract data from the ulp blob
Date: Wed, 15 Jul 2020 19:20:33 +0530 [thread overview]
Message-ID: <20200715135038.16662-6-somnath.kotur@broadcom.com> (raw)
In-Reply-To: <20200715135038.16662-1-somnath.kotur@broadcom.com>
From: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Extended the ulp blob to extract data from the blob for a given
offset and length. The support is added only for little endian
format.
Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
drivers/net/bnxt/tf_ulp/ulp_utils.c | 76 +++++++++++++++++++++++++++++++++++++
drivers/net/bnxt/tf_ulp/ulp_utils.h | 17 +++++++++
2 files changed, 93 insertions(+)
diff --git a/drivers/net/bnxt/tf_ulp/ulp_utils.c b/drivers/net/bnxt/tf_ulp/ulp_utils.c
index 3afaac6..a923da8 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_utils.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_utils.c
@@ -418,6 +418,82 @@ ulp_blob_pad_push(struct ulp_blob *blob,
return datalen;
}
+/* Get data from src and put into dst using little-endian format */
+static void
+ulp_bs_get_lsb(uint8_t *src, uint16_t bitpos, uint8_t bitlen, uint8_t *dst)
+{
+ uint8_t bitoffs = bitpos % ULP_BLOB_BYTE;
+ uint16_t index = ULP_BITS_2_BYTE_NR(bitpos);
+ uint8_t mask, partial, shift;
+
+ shift = bitoffs;
+ partial = ULP_BLOB_BYTE - bitoffs;
+ if (bitoffs + bitlen <= ULP_BLOB_BYTE) {
+ mask = ((1 << bitlen) - 1) << shift;
+ *dst = (src[index] & mask) >> shift;
+ } else {
+ mask = ((1 << partial) - 1) << shift;
+ *dst = (src[index] & mask) >> shift;
+ index++;
+ partial = bitlen - partial;
+ mask = ((1 << partial) - 1);
+ *dst |= (src[index] & mask) << (ULP_BLOB_BYTE - bitoffs);
+ }
+}
+
+/* Assuming that src is in little-Endian Format */
+static void
+ulp_bs_pull_lsb(uint8_t *src, uint8_t *dst, uint32_t size,
+ uint32_t offset, uint32_t len)
+{
+ uint32_t idx;
+ uint32_t cnt = ULP_BITS_2_BYTE_NR(len);
+
+ /* iterate bytewise to get data */
+ for (idx = 0; idx < cnt; idx++) {
+ ulp_bs_get_lsb(src, offset, ULP_BLOB_BYTE,
+ &dst[size - 1 - idx]);
+ offset += ULP_BLOB_BYTE;
+ len -= ULP_BLOB_BYTE;
+ }
+
+ /* Extract the last reminder data that is not 8 byte boundary */
+ if (len)
+ ulp_bs_get_lsb(src, offset, len, &dst[size - 1 - idx]);
+}
+
+/*
+ * 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)
+{
+ /* validate the arguments */
+ if (!blob || (offset + len) > blob->bitlen ||
+ ULP_BYTE_2_BITS(data_size) < len) {
+ BNXT_TF_DBG(ERR, "invalid argument\n");
+ return -1; /* failure */
+ }
+
+ if (blob->byte_order == BNXT_ULP_BYTE_ORDER_BE) {
+ BNXT_TF_DBG(ERR, "Big endian pull not implemented\n");
+ return -1; /* failure */
+ }
+ ulp_bs_pull_lsb(blob->data, data, data_size, offset, len);
+ return 0;
+}
+
/*
* Get the data portion of the binary blob.
*
diff --git a/drivers/net/bnxt/tf_ulp/ulp_utils.h b/drivers/net/bnxt/tf_ulp/ulp_utils.h
index 97c7750..22dfb17 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_utils.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_utils.h
@@ -229,6 +229,23 @@ 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
*
* blob [in] The blob that data is added to. The blob must
--
2.7.4
next prev parent reply other threads:[~2020-07-15 13:56 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-13 6:15 [dpdk-dev] [PATCH 00/10] bnxt patches Somnath Kotur
2020-07-13 6:15 ` [dpdk-dev] [PATCH 01/10] net/bnxt: add option to delay EEM sysmem mapping Somnath Kotur
2020-07-13 6:15 ` [dpdk-dev] [PATCH 02/10] net/bnxt: implement TF Identifier search Somnath Kotur
2020-07-13 6:15 ` [dpdk-dev] [PATCH 03/10] net/bnxt: check index range in bulk get Somnath Kotur
2020-07-13 6:15 ` [dpdk-dev] [PATCH 04/10] net/bnxt: add changes to support 2 table scopes Somnath Kotur
2020-07-13 6:15 ` [dpdk-dev] [PATCH 05/10] net/bnxt: add support to extract data from the ulp blob Somnath Kotur
2020-07-13 6:15 ` [dpdk-dev] [PATCH 06/10] net/bnxt: ignore ipv4 tos mask Somnath Kotur
2020-07-13 6:15 ` [dpdk-dev] [PATCH 07/10] net/bnxt: add support for identifier search and ref count Somnath Kotur
2020-07-13 6:15 ` [dpdk-dev] [PATCH 08/10] net/bnxt: consider vlan fields for the template match criteria Somnath Kotur
2020-07-13 6:15 ` [dpdk-dev] [PATCH 09/10] net/bnxt: increase the number of egress flow entries Somnath Kotur
2020-07-13 6:16 ` [dpdk-dev] [PATCH 10/10] net/bnxt: add support for decrement ttl action Somnath Kotur
2020-07-13 9:42 ` [dpdk-dev] [PATCH v3 00/10] bnxt patches Somnath Kotur
2020-07-13 9:42 ` [dpdk-dev] [PATCH 01/10] net/bnxt: add option to delay EEM sysmem mapping Somnath Kotur
2020-07-13 9:42 ` [dpdk-dev] [PATCH 02/10] net/bnxt: implement TF Identifier search Somnath Kotur
2020-07-13 9:42 ` [dpdk-dev] [PATCH 03/10] net/bnxt: check index range in bulk get Somnath Kotur
2020-07-13 9:42 ` [dpdk-dev] [PATCH 04/10] net/bnxt: add changes to support 2 table scopes Somnath Kotur
2020-07-13 9:42 ` [dpdk-dev] [PATCH 05/10] net/bnxt: add support to extract data from the ulp blob Somnath Kotur
2020-07-13 9:42 ` [dpdk-dev] [PATCH 06/10] net/bnxt: ignore ipv4 TOS mask Somnath Kotur
2020-07-13 9:42 ` [dpdk-dev] [PATCH 07/10] net/bnxt: add support for identifier search and ref count Somnath Kotur
2020-07-13 9:42 ` [dpdk-dev] [PATCH 08/10] net/bnxt: consider VLAN fields for template match criteria Somnath Kotur
2020-07-13 9:42 ` [dpdk-dev] [PATCH 09/10] net/bnxt: increase the number of egress flow entries Somnath Kotur
2020-07-13 9:42 ` [dpdk-dev] [PATCH 10/10] net/bnxt: add support for decrement TTL action Somnath Kotur
2020-07-14 22:36 ` [dpdk-dev] [PATCH v3 00/10] bnxt patches Ajit Khaparde
2020-07-15 12:50 ` Ferruh Yigit
2020-07-15 13:50 ` [dpdk-dev] [PATCH v4 " Somnath Kotur
2020-07-15 13:50 ` [dpdk-dev] [PATCH 01/10] net/bnxt: add option to delay EEM sysmem mapping Somnath Kotur
2020-07-15 13:50 ` [dpdk-dev] [PATCH 02/10] net/bnxt: implement TF Identifier search Somnath Kotur
2020-07-15 13:50 ` [dpdk-dev] [PATCH 03/10] net/bnxt: check index range in bulk get Somnath Kotur
2020-07-15 13:50 ` [dpdk-dev] [PATCH 04/10] net/bnxt: add changes to support 2 table scopes Somnath Kotur
2020-07-15 13:50 ` Somnath Kotur [this message]
2020-07-15 13:50 ` [dpdk-dev] [PATCH 06/10] net/bnxt: ignore ipv4 TOS mask Somnath Kotur
2020-07-15 13:50 ` [dpdk-dev] [PATCH 07/10] net/bnxt: add support for identifier search and ref count Somnath Kotur
2020-07-15 13:50 ` [dpdk-dev] [PATCH 08/10] net/bnxt: consider VLAN fields for template match criteria Somnath Kotur
2020-07-15 13:50 ` [dpdk-dev] [PATCH 09/10] net/bnxt: increase the number of egress flow entries Somnath Kotur
2020-07-15 13:50 ` [dpdk-dev] [PATCH 10/10] net/bnxt: add support for decrement TTL action Somnath Kotur
2020-07-16 23:04 ` [dpdk-dev] [PATCH v4 00/10] bnxt patches Ajit Khaparde
2020-07-13 6:28 [dpdk-dev] [v2 PATCH " Somnath Kotur
2020-07-13 6:28 ` [dpdk-dev] [PATCH 05/10] net/bnxt: add support to extract data from the ulp blob Somnath Kotur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200715135038.16662-6-somnath.kotur@broadcom.com \
--to=somnath.kotur@broadcom.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).