net/bnxt: increase counter support from 8K to 16K
[dpdk.git] / drivers / net / bnxt / tf_ulp / ulp_utils.h
index f729ff6..22dfb17 100644 (file)
@@ -7,7 +7,7 @@
 #define _ULP_UTILS_H_
 
 #include "bnxt.h"
-#include "ulp_template_db.h"
+#include "ulp_template_db_enum.h"
 
 /*
  * Macros for bitmap sets and gets
@@ -16,7 +16,7 @@
 #define ULP_BITMAP_SET(bitmap, val)    ((bitmap) |= (val))
 #define ULP_BITMAP_RESET(bitmap, val)  ((bitmap) &= ~(val))
 #define ULP_BITMAP_ISSET(bitmap, val)  ((bitmap) & (val))
-#define ULP_BITSET_CMP(b1, b2)  memcmp(&(b1)->bits, \
+#define ULP_BITMAP_CMP(b1, b2)  memcmp(&(b1)->bits, \
                                &(b2)->bits, sizeof((b1)->bits))
 /*
  * Macros for bitmap sets and gets
 /* Macro to convert bits to bytes with no round off*/
 #define ULP_BITS_2_BYTE_NR(bits_x)     ((bits_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)])
+
+#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.
  * The blob must be initialized with ulp_blob_init prior to using.
@@ -172,6 +178,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.
  *
@@ -204,6 +228,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
  *
@@ -212,9 +253,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);
 
@@ -239,6 +280,18 @@ 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);
+
 /*
  * Read data from the operand
  *
@@ -276,4 +329,13 @@ ulp_encap_buffer_copy(uint8_t *dst,
  */
 int32_t ulp_buffer_is_empty(const uint8_t *buf, uint32_t size);
 
+/* Function to check if bitmap is zero.Return 1 on success */
+uint32_t ulp_bitmap_is_zero(uint8_t *bitmap, int32_t size);
+
+/* Function to check if bitmap is ones. Return 1 on success */
+uint32_t ulp_bitmap_is_ones(uint8_t *bitmap, int32_t size);
+
+/* Function to check if bitmap is not zero. Return 1 on success */
+uint32_t ulp_bitmap_notzero(uint8_t *bitmap, int32_t size);
+
 #endif /* _ULP_UTILS_H_ */