From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: Kishore Padmanabha <kishore.padmanabha@broadcom.com>,
Mike Baucom <michael.baucom@broadcom.com>
Subject: [dpdk-dev] [PATCH v3 08/11] net/bnxt: add mapper support for wildcard TCAM
Date: Thu, 22 Oct 2020 15:05:40 -0700 [thread overview]
Message-ID: <20201022220542.84166-9-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20201020215538.59242-1-ajit.khaparde@broadcom.com>
From: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Added support for the key and mask fields encoding for the
wildcard tcam entry.
Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Reviewed-by: Mike Baucom <michael.baucom@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/tf_ulp/ulp_mapper.c | 47 ++++++++--
drivers/net/bnxt/tf_ulp/ulp_utils.c | 125 +++++++++++++++++++++++++++
drivers/net/bnxt/tf_ulp/ulp_utils.h | 48 +++++++++-
3 files changed, 212 insertions(+), 8 deletions(-)
diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index b74cb92f57..27b4780990 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -1497,6 +1497,29 @@ ulp_mapper_tcam_tbl_entry_write(struct bnxt_ulp_mapper_parms *parms,
return rc;
}
+#define BNXT_ULP_WC_TCAM_SLICE_SIZE 80
+/* internal function to post process the key/mask blobs for wildcard tcam tbl */
+static void ulp_mapper_wc_tcam_tbl_post_process(struct ulp_blob *blob,
+ uint32_t len)
+{
+ uint8_t mode[2] = {0x0, 0x0};
+ uint32_t mode_len = len / BNXT_ULP_WC_TCAM_SLICE_SIZE;
+ uint32_t size, idx;
+
+ /* Add the mode bits to the key and mask*/
+ if (mode_len == 2)
+ mode[1] = 2;
+ else if (mode_len > 2)
+ mode[1] = 3;
+
+ size = BNXT_ULP_WC_TCAM_SLICE_SIZE + ULP_BYTE_2_BITS(sizeof(mode));
+ for (idx = 0; idx < mode_len; idx++)
+ ulp_blob_insert(blob, (size * idx), mode,
+ ULP_BYTE_2_BITS(sizeof(mode)));
+ ulp_blob_perform_64B_word_swap(blob);
+ ulp_blob_perform_64B_byte_swap(blob);
+}
+
static int32_t
ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
struct bnxt_ulp_mapper_tbl_info *tbl)
@@ -1533,9 +1556,9 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
return -EINVAL;
}
- if (!ulp_blob_init(&key, tbl->key_bit_size,
+ if (!ulp_blob_init(&key, tbl->blob_key_bit_size,
parms->device_params->byte_order) ||
- !ulp_blob_init(&mask, tbl->key_bit_size,
+ !ulp_blob_init(&mask, tbl->blob_key_bit_size,
parms->device_params->byte_order) ||
!ulp_blob_init(&data, tbl->result_bit_size,
parms->device_params->byte_order) ||
@@ -1545,6 +1568,11 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
return -EINVAL;
}
+ if (tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM) {
+ key.byte_order = BNXT_ULP_BYTE_ORDER_BE;
+ mask.byte_order = BNXT_ULP_BYTE_ORDER_BE;
+ }
+
/* create the key/mask */
/*
* NOTE: The WC table will require some kind of flag to handle the
@@ -1570,6 +1598,11 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
}
}
+ if (tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM) {
+ ulp_mapper_wc_tcam_tbl_post_process(&key, tbl->key_bit_size);
+ ulp_mapper_wc_tcam_tbl_post_process(&mask, tbl->key_bit_size);
+ }
+
if (tbl->srch_b4_alloc == BNXT_ULP_SEARCH_BEFORE_ALLOC_NO) {
/*
* No search for re-use is requested, so simply allocate the
@@ -1578,18 +1611,18 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
aparms.dir = tbl->direction;
aparms.tcam_tbl_type = tbl->resource_type;
aparms.search_enable = tbl->srch_b4_alloc;
- aparms.key_sz_in_bits = tbl->key_bit_size;
aparms.key = ulp_blob_data_get(&key, &tmplen);
- if (tbl->key_bit_size != tmplen) {
+ aparms.key_sz_in_bits = tmplen;
+ if (tbl->blob_key_bit_size != tmplen) {
BNXT_TF_DBG(ERR, "Key len (%d) != Expected (%d)\n",
- tmplen, tbl->key_bit_size);
+ tmplen, tbl->blob_key_bit_size);
return -EINVAL;
}
aparms.mask = ulp_blob_data_get(&mask, &tmplen);
- if (tbl->key_bit_size != tmplen) {
+ if (tbl->blob_key_bit_size != tmplen) {
BNXT_TF_DBG(ERR, "Mask len (%d) != Expected (%d)\n",
- tmplen, tbl->key_bit_size);
+ tmplen, tbl->blob_key_bit_size);
return -EINVAL;
}
diff --git a/drivers/net/bnxt/tf_ulp/ulp_utils.c b/drivers/net/bnxt/tf_ulp/ulp_utils.c
index 24474e2e27..a13a3bbf65 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_utils.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_utils.c
@@ -273,6 +273,69 @@ ulp_blob_push(struct ulp_blob *blob,
return 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)
+{
+ uint32_t rc;
+ uint8_t local_data[BNXT_ULP_FLMP_BLOB_SIZE];
+ uint16_t mov_len;
+
+ /* validate the arguments */
+ if (!blob || datalen > (uint32_t)(blob->bitlen - blob->write_idx) ||
+ offset > blob->write_idx) {
+ BNXT_TF_DBG(ERR, "invalid argument\n");
+ return 0; /* failure */
+ }
+
+ mov_len = blob->write_idx - offset;
+ /* If offset and data len are not 8 bit aligned then return error */
+ if (ULP_BITS_IS_BYTE_NOT_ALIGNED(offset) ||
+ ULP_BITS_IS_BYTE_NOT_ALIGNED(datalen)) {
+ BNXT_TF_DBG(ERR, "invalid argument, not aligned\n");
+ return 0; /* failure */
+ }
+
+ /* copy the data so we can move the data */
+ memcpy(local_data, &blob->data[ULP_BITS_2_BYTE_NR(offset)],
+ ULP_BITS_2_BYTE(mov_len));
+ blob->write_idx = offset;
+ if (blob->byte_order == BNXT_ULP_BYTE_ORDER_BE)
+ rc = ulp_bs_push_msb(blob->data,
+ blob->write_idx,
+ datalen,
+ data);
+ else
+ rc = ulp_bs_push_lsb(blob->data,
+ blob->write_idx,
+ datalen,
+ data);
+ if (!rc) {
+ BNXT_TF_DBG(ERR, "Failed ro write blob\n");
+ return 0;
+ }
+ /* copy the previously stored data */
+ memcpy(&blob->data[ULP_BITS_2_BYTE_NR(offset + datalen)], local_data,
+ ULP_BITS_2_BYTE(mov_len));
+ blob->write_idx += (mov_len + datalen);
+ return datalen;
+}
+
/*
* Add data to the binary blob at the current offset.
*
@@ -603,6 +666,68 @@ 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)
+{
+ uint32_t i, j, num;
+ uint8_t xchar;
+ uint32_t word_size = ULP_64B_IN_BYTES / 2;
+
+ /* validate the arguments */
+ if (!blob) {
+ BNXT_TF_DBG(ERR, "invalid argument\n");
+ return; /* failure */
+ }
+ num = ULP_BITS_2_BYTE(blob->write_idx);
+ for (i = 0; i < num; i = i + ULP_64B_IN_BYTES) {
+ for (j = 0; j < word_size; j++) {
+ xchar = blob->data[i + j];
+ blob->data[i + j] = blob->data[i + j + word_size];
+ blob->data[i + j + word_size] = xchar;
+ }
+ }
+}
+
+/*
+ * 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)
+{
+ uint32_t i, j, num;
+ uint8_t xchar;
+ uint32_t offset = ULP_64B_IN_BYTES - 1;
+
+ /* validate the arguments */
+ if (!blob) {
+ BNXT_TF_DBG(ERR, "invalid argument\n");
+ return; /* failure */
+ }
+ num = ULP_BITS_2_BYTE(blob->write_idx);
+ for (i = 0; i < num; i = i + ULP_64B_IN_BYTES) {
+ for (j = 0; j < (ULP_64B_IN_BYTES / 2); j++) {
+ xchar = blob->data[i + j];
+ blob->data[i + j] = blob->data[i + offset - j];
+ blob->data[i + offset - j] = xchar;
+ }
+ }
+}
+
/*
* Read data from the operand
*
diff --git a/drivers/net/bnxt/tf_ulp/ulp_utils.h b/drivers/net/bnxt/tf_ulp/ulp_utils.h
index 898e85123e..749ac06d87 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_utils.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_utils.h
@@ -12,7 +12,7 @@
#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.
@@ -57,6 +57,9 @@
/* 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_COMP_FLD_IDX_RD(params, idx) \
rte_be_to_cpu_32((params)->comp_fld[(idx)])
@@ -167,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.
*
@@ -299,6 +321,30 @@ ulp_blob_perform_encap_swap(struct ulp_blob *blob);
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
*
--
2.21.1 (Apple Git-122.3)
next prev parent reply other threads:[~2020-10-22 22:10 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-17 6:27 [dpdk-dev] [PATCH 00/14] bnxt patches Venkat Duvvuru
2020-10-17 6:27 ` [dpdk-dev] [PATCH 01/14] net/bnxt: device cleanup of FW Venkat Duvvuru
2020-10-17 6:27 ` [dpdk-dev] [PATCH 02/14] net/bnxt: add stingray support Venkat Duvvuru
2020-10-17 6:27 ` [dpdk-dev] [PATCH 03/14] net/bnxt: changes to support 2 table scopes Venkat Duvvuru
2020-10-17 6:27 ` [dpdk-dev] [PATCH 04/14] net/bnxt: map table scope API Venkat Duvvuru
2020-10-17 6:28 ` [dpdk-dev] [PATCH 05/14] net/bnxt: table scope to PF Mapping for SR and Wh+ Venkat Duvvuru
2020-10-17 6:28 ` [dpdk-dev] [PATCH 06/14] net/bnxt: add build option for EM slot allocation Venkat Duvvuru
2020-10-17 6:28 ` [dpdk-dev] [PATCH 07/14] net/bnxt: update SR ULP resource counts Venkat Duvvuru
2020-10-17 6:28 ` [dpdk-dev] [PATCH 08/14] net/bnxt: fix infinite loop in flow query count API Venkat Duvvuru
2020-10-17 6:28 ` [dpdk-dev] [PATCH 09/14] net/bnxt: add support for parent flow accumulation counters Venkat Duvvuru
2020-10-17 6:28 ` [dpdk-dev] [PATCH 10/14] net/bnxt: use cfa pair alloc for configuring reps Venkat Duvvuru
2020-10-17 6:28 ` [dpdk-dev] [PATCH 11/14] net/bnxt: add mapper support for wildcard TCAM entry Venkat Duvvuru
2020-10-17 6:28 ` [dpdk-dev] [PATCH 12/14] net/bnxt: refactor flow id allocation Venkat Duvvuru
2020-10-17 6:28 ` [dpdk-dev] [PATCH 13/14] net/bnxt: add support for VXLAN decap templates Venkat Duvvuru
2020-10-17 6:28 ` [dpdk-dev] [PATCH 14/14] net/bnxt: add VXLAN decap offload support Venkat Duvvuru
2020-10-20 21:55 ` [dpdk-dev] [PATCH v2 00/11] bnxt fixes and enhancements to TRUFLOW support Ajit Khaparde
2020-10-20 21:55 ` [dpdk-dev] [PATCH v2 01/11] net/bnxt: add stingray support to core layer Ajit Khaparde
2020-10-21 18:07 ` Ferruh Yigit
2020-10-21 18:11 ` Ajit Khaparde
2020-10-22 9:11 ` Ferruh Yigit
2020-10-23 5:10 ` Ajit Khaparde
2020-10-20 21:55 ` [dpdk-dev] [PATCH v2 02/11] net/bnxt: changes to support two table scopes Ajit Khaparde
2020-10-20 21:55 ` [dpdk-dev] [PATCH v2 03/11] net/bnxt: add table scope to PF Mapping Ajit Khaparde
2020-10-20 21:55 ` [dpdk-dev] [PATCH v2 04/11] net/bnxt: update ULP resource counts Ajit Khaparde
2020-10-20 21:55 ` [dpdk-dev] [PATCH v2 05/11] net/bnxt: fix infinite loop in flow query count Ajit Khaparde
2020-10-20 21:55 ` [dpdk-dev] [PATCH v2 06/11] net/bnxt: add support for flow counter accumulation Ajit Khaparde
2020-10-20 21:55 ` [dpdk-dev] [PATCH v2 07/11] net/bnxt: change HWRM command to create reps Ajit Khaparde
2020-10-20 21:55 ` [dpdk-dev] [PATCH v2 08/11] net/bnxt: add mapper support for wildcard TCAM Ajit Khaparde
2020-10-20 21:55 ` [dpdk-dev] [PATCH v2 09/11] net/bnxt: refactor flow id allocation Ajit Khaparde
2020-10-20 21:55 ` [dpdk-dev] [PATCH v2 10/11] net/bnxt: add support for VXLAN decap templates Ajit Khaparde
2020-10-20 21:55 ` [dpdk-dev] [PATCH v2 11/11] net/bnxt: add VXLAN decap offload support Ajit Khaparde
2020-10-21 5:31 ` [dpdk-dev] [PATCH v2 00/11] bnxt fixes and enhancements to TRUFLOW support Ajit Khaparde
2020-10-22 22:05 ` [dpdk-dev] [PATCH v3 " Ajit Khaparde
2020-10-23 5:08 ` Ajit Khaparde
2020-10-26 3:56 ` [dpdk-dev] [PATCH v4 00/15] bnxt fixes and enhancements Ajit Khaparde
2020-10-26 3:56 ` [dpdk-dev] [PATCH v4 01/15] net/bnxt: add stingray support to core layer Ajit Khaparde
2020-10-26 3:56 ` [dpdk-dev] [PATCH v4 02/15] net/bnxt: support two table scopes Ajit Khaparde
2020-10-26 3:56 ` [dpdk-dev] [PATCH v4 03/15] net/bnxt: add table scope to PF Mapping Ajit Khaparde
2020-10-26 3:56 ` [dpdk-dev] [PATCH v4 04/15] net/bnxt: update ULP resource counts Ajit Khaparde
2020-10-26 3:56 ` [dpdk-dev] [PATCH v4 05/15] net/bnxt: fix flow query count Ajit Khaparde
2020-10-26 3:56 ` [dpdk-dev] [PATCH v4 06/15] net/bnxt: add hierarchical flow counters Ajit Khaparde
2020-10-26 3:56 ` [dpdk-dev] [PATCH v4 07/15] net/bnxt: modify HWRM command to create reps Ajit Khaparde
2020-10-26 3:56 ` [dpdk-dev] [PATCH v4 08/15] net/bnxt: add mapper support for wildcard TCAM Ajit Khaparde
2020-10-26 3:56 ` [dpdk-dev] [PATCH v4 09/15] net/bnxt: refactor flow id allocation Ajit Khaparde
2020-10-26 3:56 ` [dpdk-dev] [PATCH v4 10/15] net/bnxt: add VXLAN decap templates Ajit Khaparde
2020-10-26 3:56 ` [dpdk-dev] [PATCH v4 11/15] net/bnxt: add VXLAN decap offload support Ajit Khaparde
2020-10-26 3:56 ` [dpdk-dev] [PATCH v4 12/15] net/bnxt: increase the size of Rx CQ Ajit Khaparde
2020-10-26 3:56 ` [dpdk-dev] [PATCH v4 13/15] net/bnxt: fix to reset mbuf data offset Ajit Khaparde
2020-10-26 3:56 ` [dpdk-dev] [PATCH v4 14/15] net/bnxt: set thread safe flow ops flag Ajit Khaparde
2020-10-26 3:56 ` [dpdk-dev] [PATCH v4 15/15] net/bnxt: fix Rx performance by removing spinlock Ajit Khaparde
2020-10-26 17:42 ` [dpdk-dev] [PATCH v4 00/15] bnxt fixes and enhancements Ajit Khaparde
2020-10-22 22:05 ` [dpdk-dev] [PATCH v3 01/11] net/bnxt: add stingray support to core layer Ajit Khaparde
2020-10-23 10:54 ` Ferruh Yigit
2020-10-23 16:32 ` Ajit Khaparde
2020-10-22 22:05 ` [dpdk-dev] [PATCH v3 02/11] net/bnxt: changes to support two table scopes Ajit Khaparde
2020-10-22 22:05 ` [dpdk-dev] [PATCH v3 03/11] net/bnxt: add table scope to PF Mapping Ajit Khaparde
2020-10-22 22:05 ` [dpdk-dev] [PATCH v3 04/11] net/bnxt: update ULP resource counts Ajit Khaparde
2020-10-22 22:05 ` [dpdk-dev] [PATCH v3 05/11] net/bnxt: fix infinite loop in flow query count Ajit Khaparde
2020-10-22 22:05 ` [dpdk-dev] [PATCH v3 06/11] net/bnxt: add support for flow counter accumulation Ajit Khaparde
2020-10-22 22:05 ` [dpdk-dev] [PATCH v3 07/11] net/bnxt: change HWRM command to create reps Ajit Khaparde
2020-10-22 22:05 ` Ajit Khaparde [this message]
2020-10-22 22:05 ` [dpdk-dev] [PATCH v3 09/11] net/bnxt: refactor flow id allocation Ajit Khaparde
2020-10-22 22:05 ` [dpdk-dev] [PATCH v3 10/11] net/bnxt: add support for VXLAN decap templates Ajit Khaparde
2020-10-22 22:05 ` [dpdk-dev] [PATCH v3 11/11] net/bnxt: add VXLAN decap offload support Ajit Khaparde
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=20201022220542.84166-9-ajit.khaparde@broadcom.com \
--to=ajit.khaparde@broadcom.com \
--cc=dev@dpdk.org \
--cc=kishore.padmanabha@broadcom.com \
--cc=michael.baucom@broadcom.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).