Skip to contentSkip to conversation

add features for host-based flow management

PATCH New Somnath Kotur 3 participants 271 messages Jun 12, 2020 – Jul 7, 2020 Page 5 of 7

Subsystems (2)
lore
Share & tools
lore
#174 lore raw

PATCH v4 17/51 net/bnxt: implement support for TCAM access

In reply to Ajit Khaparde

From: Jay Ding <[email protected]>

Implement TCAM alloc, free, bind, and unbind functions Update tf_core, tf_msg, etc.

---
 drivers/net/bnxt/tf_core/tf_core.c      | 258 ++++++++++-----------
 drivers/net/bnxt/tf_core/tf_device.h    |  14 +-
 drivers/net/bnxt/tf_core/tf_device_p4.c |  25 ++-
 drivers/net/bnxt/tf_core/tf_msg.c       |  31 +--
 drivers/net/bnxt/tf_core/tf_msg.h       |   4 +-
 drivers/net/bnxt/tf_core/tf_tcam.c      | 285 +++++++++++++++++++++++-
 drivers/net/bnxt/tf_core/tf_tcam.h      |  66 ++++--
 7 files changed, 480 insertions(+), 203 deletions(-)
drivers/net/bnxt/tf_core/tf_core.c +113 -145
index 648d0d1bd..29522c66e 100644
@@ -19,43 +19,6 @@
 #include "tf_common.h"
 #include "hwrm_tf.h"
 
-static int tf_check_tcam_entry(enum tf_tcam_tbl_type tcam_tbl_type,
-			       enum tf_device_type device,
-			       uint16_t key_sz_in_bits,
-			       uint16_t *num_slice_per_row)
-{
-	uint16_t key_bytes;
-	uint16_t slice_sz = 0;
-
-#define CFA_P4_WC_TCAM_SLICES_PER_ROW 2
-#define CFA_P4_WC_TCAM_SLICE_SIZE     12
-
-	if (tcam_tbl_type == TF_TCAM_TBL_TYPE_WC_TCAM) {
-		key_bytes = TF_BITS2BYTES_WORD_ALIGN(key_sz_in_bits);
-		if (device == TF_DEVICE_TYPE_WH) {
-			slice_sz = CFA_P4_WC_TCAM_SLICE_SIZE;
-			*num_slice_per_row = CFA_P4_WC_TCAM_SLICES_PER_ROW;
-		} else {
-			TFP_DRV_LOG(ERR,
-				    "Unsupported device type %d\n",
-				    device);
-			return -ENOTSUP;
-		}
-
-		if (key_bytes > *num_slice_per_row * slice_sz) {
-			TFP_DRV_LOG(ERR,
-				    "%s: Key size %d is not supported\n",
-				    tf_tcam_tbl_2_str(tcam_tbl_type),
-				    key_bytes);
-			return -ENOTSUP;
-		}
-	} else { /* for other type of tcam */
-		*num_slice_per_row = 1;
-	}
-
-	return 0;
-}
-
 /**
  * Create EM Tbl pool of memory indexes.
  *
@@ -918,49 +881,56 @@ tf_alloc_tcam_entry(struct tf *tfp,
 		    struct tf_alloc_tcam_entry_parms *parms)
 {
 	int rc;
-	int index;
 	struct tf_session *tfs;
-	struct bitalloc *session_pool;
-	uint16_t num_slice_per_row;
-
-	/* TEMP, due to device design. When tcam is modularized device
-	 * should be retrieved from the session
-	 */
-	enum tf_device_type device_type;
-	/* TEMP */
-	device_type = TF_DEVICE_TYPE_WH;
+	struct tf_dev_info *dev;
+	struct tf_tcam_alloc_parms aparms = { 0 };
 
-	TF_CHECK_PARMS_SESSION(tfp, parms);
+	TF_CHECK_PARMS2(tfp, parms);
 
-	tfs = (struct tf_session *)(tfp->session->core_data);
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
 
-	rc = tf_check_tcam_entry(parms->tcam_tbl_type,
-				 device_type,
-				 parms->key_sz_in_bits,
-				 &num_slice_per_row);
-	/* Error logging handled by tf_check_tcam_entry */
-	if (rc)
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
 		return rc;
+	}
 
-	rc = tf_rm_lookup_tcam_type_pool(tfs,
-					 parms->dir,
-					 parms->tcam_tbl_type,
-					 &session_pool);
-	/* Error logging handled by tf_rm_lookup_tcam_type_pool */
-	if (rc)
+	if (dev->ops->tf_dev_alloc_tcam == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "%s: Operation not supported, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
 		return rc;
+	}
 
-	index = ba_alloc(session_pool);
-	if (index == BA_FAIL) {
-		TFP_DRV_LOG(ERR, "%s: %s: No resource available\n",
+	aparms.dir = parms->dir;
+	aparms.type = parms->tcam_tbl_type;
+	aparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
+	aparms.priority = parms->priority;
+	rc = dev->ops->tf_dev_alloc_tcam(tfp, &aparms);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: TCAM allocation failed, rc:%s\n",
 			    tf_dir_2_str(parms->dir),
-			    tf_tcam_tbl_2_str(parms->tcam_tbl_type));
-		return -ENOMEM;
+			    strerror(-rc));
+		return rc;
 	}
 
-	index *= num_slice_per_row;
+	parms->idx = aparms.idx;
 
-	parms->idx = index;
 	return 0;
 }
 
@@ -969,55 +939,60 @@ tf_set_tcam_entry(struct tf *tfp,
 		  struct tf_set_tcam_entry_parms *parms)
 {
 	int rc;
-	int id;
-	int index;
 	struct tf_session *tfs;
-	struct bitalloc *session_pool;
-	uint16_t num_slice_per_row;
-
-	/* TEMP, due to device design. When tcam is modularized device
-	 * should be retrieved from the session
-	 */
-	enum tf_device_type device_type;
-	/* TEMP */
-	device_type = TF_DEVICE_TYPE_WH;
+	struct tf_dev_info *dev;
+	struct tf_tcam_set_parms sparms = { 0 };
 
-	TF_CHECK_PARMS_SESSION(tfp, parms);
+	TF_CHECK_PARMS2(tfp, parms);
 
-	tfs = (struct tf_session *)(tfp->session->core_data);
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
 
-	rc = tf_check_tcam_entry(parms->tcam_tbl_type,
-				 device_type,
-				 parms->key_sz_in_bits,
-				 &num_slice_per_row);
-	/* Error logging handled by tf_check_tcam_entry */
-	if (rc)
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
 		return rc;
+	}
 
-	rc = tf_rm_lookup_tcam_type_pool(tfs,
-					 parms->dir,
-					 parms->tcam_tbl_type,
-					 &session_pool);
-	/* Error logging handled by tf_rm_lookup_tcam_type_pool */
-	if (rc)
+	if (dev->ops->tf_dev_set_tcam == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "%s: Operation not supported, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
 		return rc;
+	}
 
-	/* Verify that the entry has been previously allocated */
-	index = parms->idx / num_slice_per_row;
+	sparms.dir = parms->dir;
+	sparms.type = parms->tcam_tbl_type;
+	sparms.idx = parms->idx;
+	sparms.key = parms->key;
+	sparms.mask = parms->mask;
+	sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
+	sparms.result = parms->result;
+	sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
 
-	id = ba_inuse(session_pool, index);
-	if (id != 1) {
+	rc = dev->ops->tf_dev_set_tcam(tfp, &sparms);
+	if (rc) {
 		TFP_DRV_LOG(ERR,
-		   "%s: %s: Invalid or not allocated index, idx:%d\n",
-		   tf_dir_2_str(parms->dir),
-		   tf_tcam_tbl_2_str(parms->tcam_tbl_type),
-		   parms->idx);
-		return -EINVAL;
+			    "%s: TCAM set failed, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
 	}
 
-	rc = tf_msg_tcam_entry_set(tfp, parms);
-
-	return rc;
+	return 0;
 }
 
 int
@@ -1033,59 +1008,52 @@ tf_free_tcam_entry(struct tf *tfp,
 		   struct tf_free_tcam_entry_parms *parms)
 {
 	int rc;
-	int index;
 	struct tf_session *tfs;
-	struct bitalloc *session_pool;
-	uint16_t num_slice_per_row = 1;
-
-	/* TEMP, due to device design. When tcam is modularized device
-	 * should be retrieved from the session
-	 */
-	enum tf_device_type device_type;
-	/* TEMP */
-	device_type = TF_DEVICE_TYPE_WH;
+	struct tf_dev_info *dev;
+	struct tf_tcam_free_parms fparms = { 0 };
 
-	TF_CHECK_PARMS_SESSION(tfp, parms);
-	tfs = (struct tf_session *)(tfp->session->core_data);
+	TF_CHECK_PARMS2(tfp, parms);
 
-	rc = tf_check_tcam_entry(parms->tcam_tbl_type,
-				 device_type,
-				 0,
-				 &num_slice_per_row);
-	/* Error logging handled by tf_check_tcam_entry */
-	if (rc)
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
 		return rc;
+	}
 
-	rc = tf_rm_lookup_tcam_type_pool(tfs,
-					 parms->dir,
-					 parms->tcam_tbl_type,
-					 &session_pool);
-	/* Error logging handled by tf_rm_lookup_tcam_type_pool */
-	if (rc)
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
 		return rc;
+	}
 
-	index = parms->idx / num_slice_per_row;
-
-	rc = ba_inuse(session_pool, index);
-	if (rc == BA_FAIL || rc == BA_ENTRY_FREE) {
-		TFP_DRV_LOG(ERR, "%s: %s: Entry %d already free",
+	if (dev->ops->tf_dev_free_tcam == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "%s: Operation not supported, rc:%s\n",
 			    tf_dir_2_str(parms->dir),
-			    tf_tcam_tbl_2_str(parms->tcam_tbl_type),
-			    index);
-		return -EINVAL;
+			    strerror(-rc));
+		return rc;
 	}
 
-	ba_free(session_pool, index);
-
-	rc = tf_msg_tcam_entry_free(tfp, parms);
+	fparms.dir = parms->dir;
+	fparms.type = parms->tcam_tbl_type;
+	fparms.idx = parms->idx;
+	rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
 	if (rc) {
-		/* Log error */
-		TFP_DRV_LOG(ERR, "%s: %s: Entry %d free failed with err %s",
+		TFP_DRV_LOG(ERR,
+			    "%s: TCAM allocation failed, rc:%s\n",
 			    tf_dir_2_str(parms->dir),
-			    tf_tcam_tbl_2_str(parms->tcam_tbl_type),
-			    parms->idx,
 			    strerror(-rc));
+		return rc;
 	}
 
-	return rc;
+	return 0;
 }
drivers/net/bnxt/tf_core/tf_device.h +9 -5
index 1501b20d9..32d9a5442 100644
@@ -116,8 +116,11 @@ struct tf_dev_ops {
 	 * [in] tfp
 	 *   Pointer to TF handle
 	 *
-	 * [out] slice_size
-	 *   Pointer to slice size the device supports
+	 * [in] type
+	 *   TCAM table type
+	 *
+	 * [in] key_sz
+	 *   Key size
 	 *
 	 * [out] num_slices_per_row
 	 *   Pointer to number of slices per row the device supports
@@ -126,9 +129,10 @@ struct tf_dev_ops {
 	 *   - (0) if successful.
 	 *   - (-EINVAL) on failure.
 	 */
-	int (*tf_dev_get_wc_tcam_slices)(struct tf *tfp,
-					 uint16_t *slice_size,
-					 uint16_t *num_slices_per_row);
+	int (*tf_dev_get_tcam_slice_info)(struct tf *tfp,
+					  enum tf_tcam_tbl_type type,
+					  uint16_t key_sz,
+					  uint16_t *num_slices_per_row);
 
 	/**
 	 * Allocation of an identifier element.
drivers/net/bnxt/tf_core/tf_device_p4.c +14 -11
index f4bd95f1c..77fb693dd 100644
@@ -56,18 +56,21 @@ tf_dev_p4_get_max_types(struct tf *tfp __rte_unused,
  *   - (-EINVAL) on failure.
  */
 static int
-tf_dev_p4_get_wc_tcam_slices(struct tf *tfp __rte_unused,
-			     uint16_t *slice_size,
-			     uint16_t *num_slices_per_row)
+tf_dev_p4_get_tcam_slice_info(struct tf *tfp __rte_unused,
+			      enum tf_tcam_tbl_type type,
+			      uint16_t key_sz,
+			      uint16_t *num_slices_per_row)
 {
-#define CFA_P4_WC_TCAM_SLICE_SIZE       12
-#define CFA_P4_WC_TCAM_SLICES_PER_ROW    2
+#define CFA_P4_WC_TCAM_SLICES_PER_ROW 2
+#define CFA_P4_WC_TCAM_SLICE_SIZE     12
 
-	if (slice_size == NULL || num_slices_per_row == NULL)
-		return -EINVAL;
-
-	*slice_size = CFA_P4_WC_TCAM_SLICE_SIZE;
-	*num_slices_per_row = CFA_P4_WC_TCAM_SLICES_PER_ROW;
+	if (type == TF_TCAM_TBL_TYPE_WC_TCAM) {
+		*num_slices_per_row = CFA_P4_WC_TCAM_SLICES_PER_ROW;
+		if (key_sz > *num_slices_per_row * CFA_P4_WC_TCAM_SLICE_SIZE)
+			return -ENOTSUP;
+	} else { /* for other type of tcam */
+		*num_slices_per_row = 1;
+	}
 
 	return 0;
 }
@@ -77,7 +80,7 @@ tf_dev_p4_get_wc_tcam_slices(struct tf *tfp __rte_unused,
  */
 const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_get_max_types = tf_dev_p4_get_max_types,
-	.tf_dev_get_wc_tcam_slices = tf_dev_p4_get_wc_tcam_slices,
+	.tf_dev_get_tcam_slice_info = tf_dev_p4_get_tcam_slice_info,
 	.tf_dev_alloc_ident = tf_ident_alloc,
 	.tf_dev_free_ident = tf_ident_free,
 	.tf_dev_alloc_tbl = tf_tbl_alloc,
drivers/net/bnxt/tf_core/tf_msg.c +12 -19
index 60274eb35..b50e1d48c 100644
@@ -9,6 +9,7 @@
 #include <string.h>
 
 #include "tf_msg_common.h"
+#include "tf_device.h"
 #include "tf_msg.h"
 #include "tf_util.h"
 #include "tf_session.h"
@@ -1480,27 +1481,19 @@ tf_msg_bulk_get_tbl_entry(struct tf *tfp,
 	return tfp_le_to_cpu_32(parms.tf_resp_code);
 }
 
-#define TF_BYTES_PER_SLICE(tfp) 12
-#define NUM_SLICES(tfp, bytes) \
-	(((bytes) + TF_BYTES_PER_SLICE(tfp) - 1) / TF_BYTES_PER_SLICE(tfp))
-
 int
 tf_msg_tcam_entry_set(struct tf *tfp,
-		      struct tf_set_tcam_entry_parms *parms)
+		      struct tf_tcam_set_parms *parms)
 {
 	int rc;
 	struct tfp_send_msg_parms mparms = { 0 };
 	struct hwrm_tf_tcam_set_input req = { 0 };
 	struct hwrm_tf_tcam_set_output resp = { 0 };
-	uint16_t key_bytes =
-		TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
-	uint16_t result_bytes =
-		TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
 	struct tf_msg_dma_buf buf = { 0 };
 	uint8_t *data = NULL;
 	int data_size = 0;
 
-	rc = tf_tcam_tbl_2_hwrm(parms->tcam_tbl_type, &req.type);
+	rc = tf_tcam_tbl_2_hwrm(parms->type, &req.type);
 	if (rc != 0)
 		return rc;
 
@@ -1508,11 +1501,11 @@ tf_msg_tcam_entry_set(struct tf *tfp,
 	if (parms->dir == TF_DIR_TX)
 		req.flags |= HWRM_TF_TCAM_SET_INPUT_FLAGS_DIR_TX;
 
-	req.key_size = key_bytes;
-	req.mask_offset = key_bytes;
+	req.key_size = parms->key_size;
+	req.mask_offset = parms->key_size;
 	/* Result follows after key and mask, thus multiply by 2 */
-	req.result_offset = 2 * key_bytes;
-	req.result_size = result_bytes;
+	req.result_offset = 2 * parms->key_size;
+	req.result_size = parms->result_size;
 	data_size = 2 * req.key_size + req.result_size;
 
 	if (data_size <= TF_PCI_BUF_SIZE_MAX) {
@@ -1530,9 +1523,9 @@ tf_msg_tcam_entry_set(struct tf *tfp,
 			   sizeof(buf.pa_addr));
 	}
 
-	tfp_memcpy(&data[0], parms->key, key_bytes);
-	tfp_memcpy(&data[key_bytes], parms->mask, key_bytes);
-	tfp_memcpy(&data[req.result_offset], parms->result, result_bytes);
+	tfp_memcpy(&data[0], parms->key, parms->key_size);
+	tfp_memcpy(&data[parms->key_size], parms->mask, parms->key_size);
+	tfp_memcpy(&data[req.result_offset], parms->result, parms->result_size);
 
 	mparms.tf_type = HWRM_TF_TCAM_SET;
 	mparms.req_data = (uint32_t *)&req;
@@ -1554,7 +1547,7 @@ tf_msg_tcam_entry_set(struct tf *tfp,
 
 int
 tf_msg_tcam_entry_free(struct tf *tfp,
-		       struct tf_free_tcam_entry_parms *in_parms)
+		       struct tf_tcam_free_parms *in_parms)
 {
 	int rc;
 	struct hwrm_tf_tcam_free_input req =  { 0 };
@@ -1562,7 +1555,7 @@ tf_msg_tcam_entry_free(struct tf *tfp,
 	struct tfp_send_msg_parms parms = { 0 };
 
 	/* Populate the request */
-	rc = tf_tcam_tbl_2_hwrm(in_parms->tcam_tbl_type, &req.type);
+	rc = tf_tcam_tbl_2_hwrm(in_parms->type, &req.type);
 	if (rc != 0)
 		return rc;
 
drivers/net/bnxt/tf_core/tf_msg.h +2 -2
index 1dad2b9fb..a3e0f7bba 100644
@@ -247,7 +247,7 @@ int tf_msg_em_op(struct tf *tfp,
  *  0 on Success else internal Truflow error
  */
 int tf_msg_tcam_entry_set(struct tf *tfp,
-			  struct tf_set_tcam_entry_parms *parms);
+			  struct tf_tcam_set_parms *parms);
 
 /**
  * Sends tcam entry 'free' to the Firmware.
@@ -262,7 +262,7 @@ int tf_msg_tcam_entry_set(struct tf *tfp,
  *  0 on Success else internal Truflow error
  */
 int tf_msg_tcam_entry_free(struct tf *tfp,
-			   struct tf_free_tcam_entry_parms *parms);
+			   struct tf_tcam_free_parms *parms);
 
 /**
  * Sends Set message of a Table Type element to the firmware.
drivers/net/bnxt/tf_core/tf_tcam.c +281 -4

335 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_tcam.h +49 -17

116 lines not on this page · raw message

Signature · 1 line
2.21.1 (Apple Git-122.3)
#175 lore raw

PATCH v4 18/51 net/bnxt: multiple device implementation

In reply to Ajit Khaparde

From: Michael Wildt <[email protected]>

Implement the Identifier, Table Type and the Resource Manager modules.
Integrate Resource Manager with HCAPI.
Update open/close session.
Move to direct msgs for qcaps and resv messages.

---
 drivers/net/bnxt/tf_core/tf_core.c       | 751 ++++++++---------------
 drivers/net/bnxt/tf_core/tf_core.h       |  97 ++-
 drivers/net/bnxt/tf_core/tf_device.c     |  10 +-
 drivers/net/bnxt/tf_core/tf_device.h     |   1 +
 drivers/net/bnxt/tf_core/tf_device_p4.c  |  26 +-
 drivers/net/bnxt/tf_core/tf_identifier.c |  29 +-
 drivers/net/bnxt/tf_core/tf_identifier.h |   4 +-
 drivers/net/bnxt/tf_core/tf_msg.c        |  45 +-
 drivers/net/bnxt/tf_core/tf_msg.h        |   1 +
 drivers/net/bnxt/tf_core/tf_rm_new.c     | 225 +++++--
 drivers/net/bnxt/tf_core/tf_rm_new.h     |  11 +-
 drivers/net/bnxt/tf_core/tf_session.c    |  28 +-
 drivers/net/bnxt/tf_core/tf_session.h    |   2 +-
 drivers/net/bnxt/tf_core/tf_tbl.c        | 611 +-----------------
 drivers/net/bnxt/tf_core/tf_tbl_type.c   | 252 +++++++-
 drivers/net/bnxt/tf_core/tf_tbl_type.h   |   2 +-
 drivers/net/bnxt/tf_core/tf_tcam.c       |  12 +-
 drivers/net/bnxt/tf_core/tf_util.h       |  45 +-
 drivers/net/bnxt/tf_core/tfp.c           |   4 +-
 19 files changed, 880 insertions(+), 1276 deletions(-)
drivers/net/bnxt/tf_core/tf_core.c +250 -501
index 29522c66e..3e23d0513 100644
@@ -19,284 +19,15 @@
 #include "tf_common.h"
 #include "hwrm_tf.h"
 
-/**
- * Create EM Tbl pool of memory indexes.
- *
- * [in] session
- *   Pointer to session
- * [in] dir
- *   direction
- * [in] num_entries
- *   number of entries to write
- *
- * Return:
- *  0       - Success, entry allocated - no search support
- *  -ENOMEM -EINVAL -EOPNOTSUPP
- *          - Failure, entry not allocated, out of resources
- */
-static int
-tf_create_em_pool(struct tf_session *session,
-		  enum tf_dir dir,
-		  uint32_t num_entries)
-{
-	struct tfp_calloc_parms parms;
-	uint32_t i, j;
-	int rc = 0;
-	struct stack *pool = &session->em_pool[dir];
-
-	parms.nitems = num_entries;
-	parms.size = sizeof(uint32_t);
-	parms.alignment = 0;
-
-	if (tfp_calloc(&parms) != 0) {
-		TFP_DRV_LOG(ERR, "EM pool allocation failure %s\n",
-			    strerror(-ENOMEM));
-		return -ENOMEM;
-	}
-
-	/* Create empty stack
-	 */
-	rc = stack_init(num_entries, (uint32_t *)parms.mem_va, pool);
-
-	if (rc != 0) {
-		TFP_DRV_LOG(ERR, "EM pool stack init failure %s\n",
-			    strerror(-rc));
-		goto cleanup;
-	}
-
-	/* Fill pool with indexes
-	 */
-	j = num_entries - 1;
-
-	for (i = 0; i < num_entries; i++) {
-		rc = stack_push(pool, j);
-		if (rc != 0) {
-			TFP_DRV_LOG(ERR, "EM pool stack push failure %s\n",
-				    strerror(-rc));
-			goto cleanup;
-		}
-		j--;
-	}
-
-	if (!stack_is_full(pool)) {
-		rc = -EINVAL;
-		TFP_DRV_LOG(ERR, "EM pool stack failure %s\n",
-			    strerror(-rc));
-		goto cleanup;
-	}
-
-	return 0;
-cleanup:
-	tfp_free((void *)parms.mem_va);
-	return rc;
-}
-
-/**
- * Create EM Tbl pool of memory indexes.
- *
- * [in] session
- *   Pointer to session
- * [in] dir
- *   direction
- *
- * Return:
- */
-static void
-tf_free_em_pool(struct tf_session *session,
-		enum tf_dir dir)
-{
-	struct stack *pool = &session->em_pool[dir];
-	uint32_t *ptr;
-
-	ptr = stack_items(pool);
-
-	tfp_free(ptr);
-}
-
 int
-tf_open_session(struct tf                    *tfp,
+tf_open_session(struct tf *tfp,
 		struct tf_open_session_parms *parms)
-{
-	int rc;
-	struct tf_session *session;
-	struct tfp_calloc_parms alloc_parms;
-	unsigned int domain, bus, slot, device;
-	uint8_t fw_session_id;
-	int dir;
-
-	TF_CHECK_PARMS(tfp, parms);
-
-	/* Filter out any non-supported device types on the Core
-	 * side. It is assumed that the Firmware will be supported if
-	 * firmware open session succeeds.
-	 */
-	if (parms->device_type != TF_DEVICE_TYPE_WH) {
-		TFP_DRV_LOG(ERR,
-			    "Unsupported device type %d\n",
-			    parms->device_type);
-		return -ENOTSUP;
-	}
-
-	/* Build the beginning of session_id */
-	rc = sscanf(parms->ctrl_chan_name,
-		    "%x:%x:%x.%d",
-		    &domain,
-		    &bus,
-		    &slot,
-		    &device);
-	if (rc != 4) {
-		TFP_DRV_LOG(ERR,
-			    "Failed to scan device ctrl_chan_name\n");
-		return -EINVAL;
-	}
-
-	/* open FW session and get a new session_id */
-	rc = tf_msg_session_open(tfp,
-				 parms->ctrl_chan_name,
-				 &fw_session_id);
-	if (rc) {
-		/* Log error */
-		if (rc == -EEXIST)
-			TFP_DRV_LOG(ERR,
-				    "Session is already open, rc:%s\n",
-				    strerror(-rc));
-		else
-			TFP_DRV_LOG(ERR,
-				    "Open message send failed, rc:%s\n",
-				    strerror(-rc));
-
-		parms->session_id.id = TF_FW_SESSION_ID_INVALID;
-		return rc;
-	}
-
-	/* Allocate session */
-	alloc_parms.nitems = 1;
-	alloc_parms.size = sizeof(struct tf_session_info);
-	alloc_parms.alignment = 0;
-	rc = tfp_calloc(&alloc_parms);
-	if (rc) {
-		/* Log error */
-		TFP_DRV_LOG(ERR,
-			    "Failed to allocate session info, rc:%s\n",
-			    strerror(-rc));
-		goto cleanup;
-	}
-
-	tfp->session = (struct tf_session_info *)alloc_parms.mem_va;
-
-	/* Allocate core data for the session */
-	alloc_parms.nitems = 1;
-	alloc_parms.size = sizeof(struct tf_session);
-	alloc_parms.alignment = 0;
-	rc = tfp_calloc(&alloc_parms);
-	if (rc) {
-		/* Log error */
-		TFP_DRV_LOG(ERR,
-			    "Failed to allocate session data, rc:%s\n",
-			    strerror(-rc));
-		goto cleanup;
-	}
-
-	tfp->session->core_data = alloc_parms.mem_va;
-
-	session = (struct tf_session *)tfp->session->core_data;
-	tfp_memcpy(session->ctrl_chan_name,
-		   parms->ctrl_chan_name,
-		   TF_SESSION_NAME_MAX);
-
-	/* Initialize Session */
-	session->dev = NULL;
-	tf_rm_init(tfp);
-
-	/* Construct the Session ID */
-	session->session_id.internal.domain = domain;
-	session->session_id.internal.bus = bus;
-	session->session_id.internal.device = device;
-	session->session_id.internal.fw_session_id = fw_session_id;
-
-	/* Query for Session Config
-	 */
-	rc = tf_msg_session_qcfg(tfp);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Query config message send failed, rc:%s\n",
-			    strerror(-rc));
-		goto cleanup_close;
-	}
-
-	/* Shadow DB configuration */
-	if (parms->shadow_copy) {
-		/* Ignore shadow_copy setting */
-		session->shadow_copy = 0;/* parms->shadow_copy; */
-#if (TF_SHADOW == 1)
-		rc = tf_rm_shadow_db_init(tfs);
-		if (rc)
-			TFP_DRV_LOG(ERR,
-				    "Shadow DB Initialization failed\n, rc:%s",
-				    strerror(-rc));
-		/* Add additional processing */
-#endif /* TF_SHADOW */
-	}
-
-	/* Adjust the Session with what firmware allowed us to get */
-	rc = tf_rm_allocate_validate(tfp);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Rm allocate validate failed, rc:%s\n",
-			    strerror(-rc));
-		goto cleanup_close;
-	}
-
-	/* Initialize EM pool */
-	for (dir = 0; dir < TF_DIR_MAX; dir++) {
-		rc = tf_create_em_pool(session,
-				       (enum tf_dir)dir,
-				       TF_SESSION_EM_POOL_SIZE);
-		if (rc) {
-			TFP_DRV_LOG(ERR,
-				    "EM Pool initialization failed\n");
-			goto cleanup_close;
-		}
-	}
-
-	session->ref_count++;
-
-	/* Return session ID */
-	parms->session_id = session->session_id;
-
-	TFP_DRV_LOG(INFO,
-		    "Session created, session_id:%d\n",
-		    parms->session_id.id);
-
-	TFP_DRV_LOG(INFO,
-		    "domain:%d, bus:%d, device:%d, fw_session_id:%d\n",
-		    parms->session_id.internal.domain,
-		    parms->session_id.internal.bus,
-		    parms->session_id.internal.device,
-		    parms->session_id.internal.fw_session_id);
-
-	return 0;
-
- cleanup:
-	tfp_free(tfp->session->core_data);
-	tfp_free(tfp->session);
-	tfp->session = NULL;
-	return rc;
-
- cleanup_close:
-	tf_close_session(tfp);
-	return -EINVAL;
-}
-
-int
-tf_open_session_new(struct tf *tfp,
-		    struct tf_open_session_parms *parms)
 {
 	int rc;
 	unsigned int domain, bus, slot, device;
 	struct tf_session_open_session_parms oparms;
 
-	TF_CHECK_PARMS(tfp, parms);
+	TF_CHECK_PARMS2(tfp, parms);
 
 	/* Filter out any non-supported device types on the Core
 	 * side. It is assumed that the Firmware will be supported if
@@ -347,33 +78,8 @@ tf_open_session_new(struct tf *tfp,
 }
 
 int
-tf_attach_session(struct tf *tfp __rte_unused,
-		  struct tf_attach_session_parms *parms __rte_unused)
-{
-#if (TF_SHARED == 1)
-	int rc;
-
-	TF_CHECK_PARMS_SESSION(tfp, parms);
-
-	/* - Open the shared memory for the attach_chan_name
-	 * - Point to the shared session for this Device instance
-	 * - Check that session is valid
-	 * - Attach to the firmware so it can record there is more
-	 *   than one client of the session.
-	 */
-
-	if (tfp->session->session_id.id != TF_SESSION_ID_INVALID) {
-		rc = tf_msg_session_attach(tfp,
-					   parms->ctrl_chan_name,
-					   parms->session_id);
-	}
-#endif /* TF_SHARED */
-	return -1;
-}
-
-int
-tf_attach_session_new(struct tf *tfp,
-		      struct tf_attach_session_parms *parms)
+tf_attach_session(struct tf *tfp,
+		  struct tf_attach_session_parms *parms)
 {
 	int rc;
 	unsigned int domain, bus, slot, device;
@@ -436,65 +142,6 @@ tf_attach_session_new(struct tf *tfp,
 
 int
 tf_close_session(struct tf *tfp)
-{
-	int rc;
-	int rc_close = 0;
-	struct tf_session *tfs;
-	union tf_session_id session_id;
-	int dir;
-
-	TF_CHECK_TFP_SESSION(tfp);
-
-	tfs = (struct tf_session *)(tfp->session->core_data);
-
-	/* Cleanup if we're last user of the session */
-	if (tfs->ref_count == 1) {
-		/* Cleanup any outstanding resources */
-		rc_close = tf_rm_close(tfp);
-	}
-
-	if (tfs->session_id.id != TF_SESSION_ID_INVALID) {
-		rc = tf_msg_session_close(tfp);
-		if (rc) {
-			/* Log error */
-			TFP_DRV_LOG(ERR,
-				    "Message send failed, rc:%s\n",
-				    strerror(-rc));
-		}
-
-		/* Update the ref_count */
-		tfs->ref_count--;
-	}
-
-	session_id = tfs->session_id;
-
-	/* Final cleanup as we're last user of the session */
-	if (tfs->ref_count == 0) {
-		/* Free EM pool */
-		for (dir = 0; dir < TF_DIR_MAX; dir++)
-			tf_free_em_pool(tfs, (enum tf_dir)dir);
-
-		tfp_free(tfp->session->core_data);
-		tfp_free(tfp->session);
-		tfp->session = NULL;
-	}
-
-	TFP_DRV_LOG(INFO,
-		    "Session closed, session_id:%d\n",
-		    session_id.id);
-
-	TFP_DRV_LOG(INFO,
-		    "domain:%d, bus:%d, device:%d, fw_session_id:%d\n",
-		    session_id.internal.domain,
-		    session_id.internal.bus,
-		    session_id.internal.device,
-		    session_id.internal.fw_session_id);
-
-	return rc_close;
-}
-
-int
-tf_close_session_new(struct tf *tfp)
 {
 	int rc;
 	struct tf_session_close_session_parms cparms = { 0 };
@@ -620,76 +267,9 @@ int tf_delete_em_entry(struct tf *tfp,
 	return rc;
 }
 
-int tf_alloc_identifier(struct tf *tfp,
-			struct tf_alloc_identifier_parms *parms)
-{
-	struct bitalloc *session_pool;
-	struct tf_session *tfs;
-	int id;
-	int rc;
-
-	TF_CHECK_PARMS_SESSION(tfp, parms);
-
-	tfs = (struct tf_session *)(tfp->session->core_data);
-
-	switch (parms->ident_type) {
-	case TF_IDENT_TYPE_L2_CTXT:
-		TF_RM_GET_POOLS(tfs, parms->dir, &session_pool,
-				TF_L2_CTXT_REMAP_POOL_NAME,
-				rc);
-		break;
-	case TF_IDENT_TYPE_PROF_FUNC:
-		TF_RM_GET_POOLS(tfs, parms->dir, &session_pool,
-				TF_PROF_FUNC_POOL_NAME,
-				rc);
-		break;
-	case TF_IDENT_TYPE_EM_PROF:
-		TF_RM_GET_POOLS(tfs, parms->dir, &session_pool,
-				TF_EM_PROF_ID_POOL_NAME,
-				rc);
-		break;
-	case TF_IDENT_TYPE_WC_PROF:
-		TF_RM_GET_POOLS(tfs, parms->dir, &session_pool,
-				TF_WC_TCAM_PROF_ID_POOL_NAME,
-				rc);
-		break;
-	case TF_IDENT_TYPE_L2_FUNC:
-		TFP_DRV_LOG(ERR, "%s: unsupported %s\n",
-			    tf_dir_2_str(parms->dir),
-			    tf_ident_2_str(parms->ident_type));
-		rc = -EOPNOTSUPP;
-		break;
-	default:
-		TFP_DRV_LOG(ERR, "%s: %s\n",
-			    tf_dir_2_str(parms->dir),
-			    tf_ident_2_str(parms->ident_type));
-		rc = -EOPNOTSUPP;
-		break;
-	}
-
-	if (rc) {
-		TFP_DRV_LOG(ERR, "%s: identifier pool %s failure, rc:%s\n",
-			    tf_dir_2_str(parms->dir),
-			    tf_ident_2_str(parms->ident_type),
-			    strerror(-rc));
-		return rc;
-	}
-
-	id = ba_alloc(session_pool);
-
-	if (id == BA_FAIL) {
-		TFP_DRV_LOG(ERR, "%s: %s: No resource available\n",
-			    tf_dir_2_str(parms->dir),
-			    tf_ident_2_str(parms->ident_type));
-		return -ENOMEM;
-	}
-	parms->id = id;
-	return 0;
-}
-
 int
-tf_alloc_identifier_new(struct tf *tfp,
-			struct tf_alloc_identifier_parms *parms)
+tf_alloc_identifier(struct tf *tfp,
+		    struct tf_alloc_identifier_parms *parms)
 {
 	int rc;
 	struct tf_session *tfs;
@@ -732,7 +312,7 @@ tf_alloc_identifier_new(struct tf *tfp,
 	}
 
 	aparms.dir = parms->dir;
-	aparms.ident_type = parms->ident_type;
+	aparms.type = parms->ident_type;
 	aparms.id = &id;
 	rc = dev->ops->tf_dev_alloc_ident(tfp, &aparms);
 	if (rc) {
@@ -748,79 +328,9 @@ tf_alloc_identifier_new(struct tf *tfp,
 	return 0;
 }
 
-int tf_free_identifier(struct tf *tfp,
-		       struct tf_free_identifier_parms *parms)
-{
-	struct bitalloc *session_pool;
-	int rc;
-	int ba_rc;
-	struct tf_session *tfs;
-
-	TF_CHECK_PARMS_SESSION(tfp, parms);
-
-	tfs = (struct tf_session *)(tfp->session->core_data);
-
-	switch (parms->ident_type) {
-	case TF_IDENT_TYPE_L2_CTXT:
-		TF_RM_GET_POOLS(tfs, parms->dir, &session_pool,
-				TF_L2_CTXT_REMAP_POOL_NAME,
-				rc);
-		break;
-	case TF_IDENT_TYPE_PROF_FUNC:
-		TF_RM_GET_POOLS(tfs, parms->dir, &session_pool,
-				TF_PROF_FUNC_POOL_NAME,
-				rc);
-		break;
-	case TF_IDENT_TYPE_EM_PROF:
-		TF_RM_GET_POOLS(tfs, parms->dir, &session_pool,
-				TF_EM_PROF_ID_POOL_NAME,
-				rc);
-		break;
-	case TF_IDENT_TYPE_WC_PROF:
-		TF_RM_GET_POOLS(tfs, parms->dir, &session_pool,
-				TF_WC_TCAM_PROF_ID_POOL_NAME,
-				rc);
-		break;
-	case TF_IDENT_TYPE_L2_FUNC:
-		TFP_DRV_LOG(ERR, "%s: unsupported %s\n",
-			    tf_dir_2_str(parms->dir),
-			    tf_ident_2_str(parms->ident_type));
-		rc = -EOPNOTSUPP;
-		break;
-	default:
-		TFP_DRV_LOG(ERR, "%s: invalid %s\n",
-			    tf_dir_2_str(parms->dir),
-			    tf_ident_2_str(parms->ident_type));
-		rc = -EOPNOTSUPP;
-		break;
-	}
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "%s: %s Identifier pool access failed, rc:%s\n",
-			    tf_dir_2_str(parms->dir),
-			    tf_ident_2_str(parms->ident_type),
-			    strerror(-rc));
-		return rc;
-	}
-
-	ba_rc = ba_inuse(session_pool, (int)parms->id);
-
-	if (ba_rc == BA_FAIL || ba_rc == BA_ENTRY_FREE) {
-		TFP_DRV_LOG(ERR, "%s: %s: Entry %d already free",
-			    tf_dir_2_str(parms->dir),
-			    tf_ident_2_str(parms->ident_type),
-			    parms->id);
-		return -EINVAL;
-	}
-
-	ba_free(session_pool, (int)parms->id);
-
-	return 0;
-}
-
 int
-tf_free_identifier_new(struct tf *tfp,
-		       struct tf_free_identifier_parms *parms)
+tf_free_identifier(struct tf *tfp,
+		   struct tf_free_identifier_parms *parms)
 {
 	int rc;
 	struct tf_session *tfs;
@@ -862,12 +372,12 @@ tf_free_identifier_new(struct tf *tfp,
 	}
 
 	fparms.dir = parms->dir;
-	fparms.ident_type = parms->ident_type;
+	fparms.type = parms->ident_type;
 	fparms.id = parms->id;
 	rc = dev->ops->tf_dev_free_ident(tfp, &fparms);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
-			    "%s: Identifier allocation failed, rc:%s\n",
+			    "%s: Identifier free failed, rc:%s\n",
 			    tf_dir_2_str(parms->dir),
 			    strerror(-rc));
 		return rc;
@@ -1057,3 +567,242 @@ tf_free_tcam_entry(struct tf *tfp,
 
 	return 0;
 }
+
+int
+tf_alloc_tbl_entry(struct tf *tfp,
+		   struct tf_alloc_tbl_entry_parms *parms)
+{
+	int rc;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	struct tf_tbl_alloc_parms aparms;
+	uint32_t idx;
+
+	TF_CHECK_PARMS2(tfp, parms);
+
+	/* Can't do static initialization due to UT enum check */
+	memset(&aparms, 0, sizeof(struct tf_tbl_alloc_parms));
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	if (dev->ops->tf_dev_alloc_tbl == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "%s: Operation not supported, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return -EOPNOTSUPP;
+	}
+
+	aparms.dir = parms->dir;
+	aparms.type = parms->type;
+	aparms.idx = &idx;
+	rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Table allocation failed, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	parms->idx = idx;
+
+	return 0;
+}
+
+int
+tf_free_tbl_entry(struct tf *tfp,
+		  struct tf_free_tbl_entry_parms *parms)
+{
+	int rc;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	struct tf_tbl_free_parms fparms;
+
+	TF_CHECK_PARMS2(tfp, parms);
+
+	/* Can't do static initialization due to UT enum check */
+	memset(&fparms, 0, sizeof(struct tf_tbl_free_parms));
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	if (dev->ops->tf_dev_free_tbl == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "%s: Operation not supported, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return -EOPNOTSUPP;
+	}
+
+	fparms.dir = parms->dir;
+	fparms.type = parms->type;
+	fparms.idx = parms->idx;
+	rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Table free failed, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	return 0;
+}
+
+int
+tf_set_tbl_entry(struct tf *tfp,
+		 struct tf_set_tbl_entry_parms *parms)
+{
+	int rc = 0;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	struct tf_tbl_set_parms sparms;
+
+	TF_CHECK_PARMS3(tfp, parms, parms->data);
+
+	/* Can't do static initialization due to UT enum check */
+	memset(&sparms, 0, sizeof(struct tf_tbl_set_parms));
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	if (dev->ops->tf_dev_set_tbl == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "%s: Operation not supported, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return -EOPNOTSUPP;
+	}
+
+	sparms.dir = parms->dir;
+	sparms.type = parms->type;
+	sparms.data = parms->data;
+	sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
+	sparms.idx = parms->idx;
+	rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Table set failed, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	return rc;
+}
+
+int
+tf_get_tbl_entry(struct tf *tfp,
+		 struct tf_get_tbl_entry_parms *parms)
+{
+	int rc = 0;
+	struct tf_session *tfs;
+	struct tf_dev_info *dev;
+	struct tf_tbl_get_parms gparms;
+
+	TF_CHECK_PARMS3(tfp, parms, parms->data);
+
+	/* Can't do static initialization due to UT enum check */
+	memset(&gparms, 0, sizeof(struct tf_tbl_get_parms));
+
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Retrieve the device information */
+	rc = tf_session_get_device(tfs, &dev);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup device, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	if (dev->ops->tf_dev_get_tbl == NULL) {
+		rc = -EOPNOTSUPP;
+		TFP_DRV_LOG(ERR,
+			    "%s: Operation not supported, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return -EOPNOTSUPP;
+	}
+
+	gparms.dir = parms->dir;
+	gparms.type = parms->type;
+	gparms.data = parms->data;
+	gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
+	gparms.idx = parms->idx;
+	rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Table get failed, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	return rc;
+}
drivers/net/bnxt/tf_core/tf_core.h +70 -27

151 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_device.c +9 -1
index 4c46cadc6..b474e8c25 100644
@@ -43,6 +43,14 @@ dev_bind_p4(struct tf *tfp,
 	struct tf_tbl_cfg_parms tbl_cfg;
 	struct tf_tcam_cfg_parms tcam_cfg;
 
+	dev_handle->type = TF_DEVICE_TYPE_WH;
+	/* Initial function initialization */
+	dev_handle->ops = &tf_dev_ops_p4_init;
+
+	dev_handle->type = TF_DEVICE_TYPE_WH;
+	/* Initial function initialization */
+	dev_handle->ops = &tf_dev_ops_p4_init;
+
 	/* Initialize the modules */
 
 	ident_cfg.num_elements = TF_IDENT_TYPE_MAX;
@@ -78,7 +86,7 @@ dev_bind_p4(struct tf *tfp,
 		goto fail;
 	}
 
-	dev_handle->type = TF_DEVICE_TYPE_WH;
+	/* Final function initialization */
 	dev_handle->ops = &tf_dev_ops_p4;
 
 	return 0;
drivers/net/bnxt/tf_core/tf_device.h +1 -0
index 32d9a5442..c31bf2357 100644
@@ -407,6 +407,7 @@ struct tf_dev_ops {
 /**
  * Supported device operation structures
  */
+extern const struct tf_dev_ops tf_dev_ops_p4_init;
 extern const struct tf_dev_ops tf_dev_ops_p4;
 
 #endif /* _TF_DEVICE_H_ */
drivers/net/bnxt/tf_core/tf_device_p4.c +23 -3
index 77fb693dd..9e332c594 100644
@@ -75,6 +75,26 @@ tf_dev_p4_get_tcam_slice_info(struct tf *tfp __rte_unused,
 	return 0;
 }
 
+/**
+ * Truflow P4 device specific functions
+ */
+const struct tf_dev_ops tf_dev_ops_p4_init = {
+	.tf_dev_get_max_types = tf_dev_p4_get_max_types,
+	.tf_dev_get_tcam_slice_info = tf_dev_p4_get_tcam_slice_info,
+	.tf_dev_alloc_ident = NULL,
+	.tf_dev_free_ident = NULL,
+	.tf_dev_alloc_tbl = NULL,
+	.tf_dev_free_tbl = NULL,
+	.tf_dev_alloc_search_tbl = NULL,
+	.tf_dev_set_tbl = NULL,
+	.tf_dev_get_tbl = NULL,
+	.tf_dev_alloc_tcam = NULL,
+	.tf_dev_free_tcam = NULL,
+	.tf_dev_alloc_search_tcam = NULL,
+	.tf_dev_set_tcam = NULL,
+	.tf_dev_get_tcam = NULL,
+};
+
 /**
  * Truflow P4 device specific functions
  */
@@ -85,14 +105,14 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_free_ident = tf_ident_free,
 	.tf_dev_alloc_tbl = tf_tbl_alloc,
 	.tf_dev_free_tbl = tf_tbl_free,
-	.tf_dev_alloc_search_tbl = tf_tbl_alloc_search,
+	.tf_dev_alloc_search_tbl = NULL,
 	.tf_dev_set_tbl = tf_tbl_set,
 	.tf_dev_get_tbl = tf_tbl_get,
 	.tf_dev_alloc_tcam = tf_tcam_alloc,
 	.tf_dev_free_tcam = tf_tcam_free,
-	.tf_dev_alloc_search_tcam = tf_tcam_alloc_search,
+	.tf_dev_alloc_search_tcam = NULL,
 	.tf_dev_set_tcam = tf_tcam_set,
-	.tf_dev_get_tcam = tf_tcam_get,
+	.tf_dev_get_tcam = NULL,
 	.tf_dev_insert_em_entry = tf_em_insert_entry,
 	.tf_dev_delete_em_entry = tf_em_delete_entry,
 };
drivers/net/bnxt/tf_core/tf_identifier.c +19 -10
index e89f9768b..ee07a6aea 100644
@@ -45,19 +45,22 @@ tf_ident_bind(struct tf *tfp,
 		db_cfg.dir = i;
 		db_cfg.num_elements = parms->num_elements;
 		db_cfg.cfg = parms->cfg;
-		db_cfg.alloc_num = parms->resources->identifier_cnt[i];
-		db_cfg.rm_db = ident_db[i];
+		db_cfg.alloc_cnt = parms->resources->ident_cnt[i].cnt;
+		db_cfg.rm_db = &ident_db[i];
 		rc = tf_rm_create_db(tfp, &db_cfg);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
 				    "%s: Identifier DB creation failed\n",
 				    tf_dir_2_str(i));
+
 			return rc;
 		}
 	}
 
 	init = 1;
 
+	printf("Identifier - initialized\n");
+
 	return 0;
 }
 
@@ -73,8 +76,11 @@ tf_ident_unbind(struct tf *tfp __rte_unused)
 	/* Bail if nothing has been initialized done silent as to
 	 * allow for creation cleanup.
 	 */
-	if (!init)
+	if (!init) {
+		TFP_DRV_LOG(ERR,
+			    "No Identifier DBs created\n");
 		return -EINVAL;
+	}
 
 	for (i = 0; i < TF_DIR_MAX; i++) {
 		fparms.dir = i;
@@ -96,6 +102,7 @@ tf_ident_alloc(struct tf *tfp __rte_unused,
 	       struct tf_ident_alloc_parms *parms)
 {
 	int rc;
+	uint32_t id;
 	struct tf_rm_allocate_parms aparms = { 0 };
 
 	TF_CHECK_PARMS2(tfp, parms);
@@ -109,17 +116,19 @@ tf_ident_alloc(struct tf *tfp __rte_unused,
 
 	/* Allocate requested element */
 	aparms.rm_db = ident_db[parms->dir];
-	aparms.db_index = parms->ident_type;
-	aparms.index = (uint32_t *)&parms->id;
+	aparms.db_index = parms->type;
+	aparms.index = &id;
 	rc = tf_rm_allocate(&aparms);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
 			    "%s: Failed allocate, type:%d\n",
 			    tf_dir_2_str(parms->dir),
-			    parms->ident_type);
+			    parms->type);
 		return rc;
 	}
 
+	*parms->id = id;
+
 	return 0;
 }
 
@@ -143,7 +152,7 @@ tf_ident_free(struct tf *tfp __rte_unused,
 
 	/* Check if element is in use */
 	aparms.rm_db = ident_db[parms->dir];
-	aparms.db_index = parms->ident_type;
+	aparms.db_index = parms->type;
 	aparms.index = parms->id;
 	aparms.allocated = &allocated;
 	rc = tf_rm_is_allocated(&aparms);
@@ -154,21 +163,21 @@ tf_ident_free(struct tf *tfp __rte_unused,
 		TFP_DRV_LOG(ERR,
 			    "%s: Entry already free, type:%d, index:%d\n",
 			    tf_dir_2_str(parms->dir),
-			    parms->ident_type,
+			    parms->type,
 			    parms->id);
 		return rc;
 	}
 
 	/* Free requested element */
 	fparms.rm_db = ident_db[parms->dir];
-	fparms.db_index = parms->ident_type;
+	fparms.db_index = parms->type;
 	fparms.index = parms->id;
 	rc = tf_rm_free(&fparms);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
 			    "%s: Free failed, type:%d, index:%d\n",
 			    tf_dir_2_str(parms->dir),
-			    parms->ident_type,
+			    parms->type,
 			    parms->id);
 		return rc;
 	}
drivers/net/bnxt/tf_core/tf_identifier.h +2 -2
index 1c5319b5e..6e36c525f 100644
@@ -43,7 +43,7 @@ struct tf_ident_alloc_parms {
 	/**
 	 * [in] Identifier type
 	 */
-	enum tf_identifier_type ident_type;
+	enum tf_identifier_type type;
 	/**
 	 * [out] Identifier allocated
 	 */
@@ -61,7 +61,7 @@ struct tf_ident_free_parms {
 	/**
 	 * [in] Identifier type
 	 */
-	enum tf_identifier_type ident_type;
+	enum tf_identifier_type type;
 	/**
 	 * [in] ID to free
 	 */
drivers/net/bnxt/tf_core/tf_msg.c +32 -13

115 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_msg.h +1 -0
index a3e0f7bba..fb635f6dc 100644
@@ -12,6 +12,7 @@
 #include "tf_tbl.h"
 #include "tf_rm.h"
 #include "tf_rm_new.h"
+#include "tf_tcam.h"
 
 struct tf;
 
drivers/net/bnxt/tf_core/tf_rm_new.c +175 -50

374 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_rm_new.h +7 -4
index 6d8234ddc..ebf38c411 100644
@@ -135,13 +135,16 @@ struct tf_rm_create_db_parms {
 	 */
 	struct tf_rm_element_cfg *cfg;
 	/**
-	 * Allocation number array. Array size is num_elements.
+	 * Resource allocation count array. This array content
+	 * originates from the tf_session_resources that is passed in
+	 * on session open.
+	 * Array size is num_elements.
 	 */
-	uint16_t *alloc_num;
+	uint16_t *alloc_cnt;
 	/**
 	 * [out] RM DB Handle
 	 */
-	void *rm_db;
+	void **rm_db;
 };
 
 /**
@@ -382,7 +385,7 @@ int tf_rm_get_info(struct tf_rm_get_alloc_info_parms *parms);
 
 /**
  * Performs a lookup in the Resource Manager DB and retrives the
- * requested HCAPI type.
+ * requested HCAPI RM type.
  *
  * [in] parms
  *   Pointer to get hcapi parameters
drivers/net/bnxt/tf_core/tf_session.c +2 -26
index 1917f8100..3a602618c 100644
@@ -95,21 +95,11 @@ tf_session_open_session(struct tf *tfp,
 		      parms->open_cfg->device_type,
 		      session->shadow_copy,
 		      &parms->open_cfg->resources,
-		      session->dev);
+		      &session->dev);
 	/* Logging handled by dev_bind */
 	if (rc)
 		return rc;
 
-	/* Query for Session Config
-	 */
-	rc = tf_msg_session_qcfg(tfp);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Query config message send failed, rc:%s\n",
-			    strerror(-rc));
-		goto cleanup_close;
-	}
-
 	session->ref_count++;
 
 	return 0;
@@ -119,10 +109,6 @@ tf_session_open_session(struct tf *tfp,
 	tfp_free(tfp->session);
 	tfp->session = NULL;
 	return rc;
-
- cleanup_close:
-	tf_close_session(tfp);
-	return -EINVAL;
 }
 
 int
@@ -231,17 +217,7 @@ int
 tf_session_get_device(struct tf_session *tfs,
 		      struct tf_dev_info **tfd)
 {
-	int rc;
-
-	if (tfs->dev == NULL) {
-		rc = -EINVAL;
-		TFP_DRV_LOG(ERR,
-			    "Device not created, rc:%s\n",
-			    strerror(-rc));
-		return rc;
-	}
-
-	*tfd = tfs->dev;
+	*tfd = &tfs->dev;
 
 	return 0;
 }
drivers/net/bnxt/tf_core/tf_session.h +1 -1
index 92792518b..705bb0955 100644
@@ -97,7 +97,7 @@ struct tf_session {
 	uint8_t ref_count;
 
 	/** Device handle */
-	struct tf_dev_info *dev;
+	struct tf_dev_info dev;
 
 	/** Session HW and SRAM resources */
 	struct tf_rm_db resc;
drivers/net/bnxt/tf_core/tf_tbl.c +1 -610

635 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_tbl_type.c +242 -10

306 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_tbl_type.h +1 -1
index 11f2aa333..3474489a6 100644
@@ -55,7 +55,7 @@ struct tf_tbl_alloc_parms {
 	/**
 	 * [out] Idx of allocated entry or found entry (if search_enable)
 	 */
-	uint32_t idx;
+	uint32_t *idx;
 };
 
 /**
drivers/net/bnxt/tf_core/tf_tcam.c +7 -5
index b9dba5323..e0fac31f2 100644
@@ -38,8 +38,8 @@ static uint8_t init;
 /* static uint8_t shadow_init; */
 
 int
-tf_tcam_bind(struct tf *tfp __rte_unused,
-	     struct tf_tcam_cfg_parms *parms __rte_unused)
+tf_tcam_bind(struct tf *tfp,
+	     struct tf_tcam_cfg_parms *parms)
 {
 	int rc;
 	int i;
@@ -59,8 +59,8 @@ tf_tcam_bind(struct tf *tfp __rte_unused,
 		db_cfg.dir = i;
 		db_cfg.num_elements = parms->num_elements;
 		db_cfg.cfg = parms->cfg;
-		db_cfg.alloc_num = parms->resources->tcam_tbl_cnt[i];
-		db_cfg.rm_db = tcam_db[i];
+		db_cfg.alloc_cnt = parms->resources->tcam_cnt[i].cnt;
+		db_cfg.rm_db = &tcam_db[i];
 		rc = tf_rm_create_db(tfp, &db_cfg);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
@@ -72,11 +72,13 @@ tf_tcam_bind(struct tf *tfp __rte_unused,
 
 	init = 1;
 
+	printf("TCAM - initialized\n");
+
 	return 0;
 }
 
 int
-tf_tcam_unbind(struct tf *tfp __rte_unused)
+tf_tcam_unbind(struct tf *tfp)
 {
 	int rc;
 	int i;
drivers/net/bnxt/tf_core/tf_util.h +35 -10

67 lines not on this page · raw message

drivers/net/bnxt/tf_core/tfp.c +2 -2
index 3bce3ade1..69d1c9a1f 100644
@@ -102,13 +102,13 @@ tfp_calloc(struct tfp_calloc_parms *parms)
 				    (parms->nitems * parms->size),
 				    parms->alignment);
 	if (parms->mem_va == NULL) {
-		PMD_DRV_LOG(ERR, "Allocate failed mem_va\n");
+		TFP_DRV_LOG(ERR, "Allocate failed mem_va\n");
 		return -ENOMEM;
 	}
 
 	parms->mem_pa = (void *)((uintptr_t)rte_mem_virt2iova(parms->mem_va));
 	if (parms->mem_pa == (void *)((uintptr_t)RTE_BAD_IOVA)) {
-		PMD_DRV_LOG(ERR, "Allocate failed mem_pa\n");
+		TFP_DRV_LOG(ERR, "Allocate failed mem_pa\n");
 		return -ENOMEM;
 	}
 
Signature · 1 line
2.21.1 (Apple Git-122.3)
#176 lore raw

PATCH v4 19/51 net/bnxt: update identifier with remap support

In reply to Ajit Khaparde

From: Michael Wildt <[email protected]>

- Add Identifier L2 CTXT Remap to the P4 device and updated the cfa_resource_types.h to get the type support.

---
 drivers/net/bnxt/tf_core/cfa_resource_types.h | 110 ++++++++++--------
 drivers/net/bnxt/tf_core/tf_device_p4.h       |   2 +-
 2 files changed, 60 insertions(+), 52 deletions(-)
drivers/net/bnxt/tf_core/cfa_resource_types.h +59 -51
index 11e8892f4..058d8cc88 100644
@@ -20,46 +20,48 @@
 
 /* L2 Context TCAM */
 #define CFA_RESOURCE_TYPE_P59_L2_CTXT_TCAM    0x0UL
+/* L2 Context REMAP */
+#define CFA_RESOURCE_TYPE_P59_L2_CTXT_REMAP   0x1UL
 /* Profile Func */
-#define CFA_RESOURCE_TYPE_P59_PROF_FUNC       0x1UL
+#define CFA_RESOURCE_TYPE_P59_PROF_FUNC       0x2UL
 /* Profile TCAM */
-#define CFA_RESOURCE_TYPE_P59_PROF_TCAM       0x2UL
+#define CFA_RESOURCE_TYPE_P59_PROF_TCAM       0x3UL
 /* Exact Match Profile Id */
-#define CFA_RESOURCE_TYPE_P59_EM_PROF_ID      0x3UL
+#define CFA_RESOURCE_TYPE_P59_EM_PROF_ID      0x4UL
 /* Wildcard TCAM Profile Id */
-#define CFA_RESOURCE_TYPE_P59_WC_TCAM_PROF_ID 0x4UL
+#define CFA_RESOURCE_TYPE_P59_WC_TCAM_PROF_ID 0x5UL
 /* Wildcard TCAM */
-#define CFA_RESOURCE_TYPE_P59_WC_TCAM         0x5UL
+#define CFA_RESOURCE_TYPE_P59_WC_TCAM         0x6UL
 /* Meter Profile */
-#define CFA_RESOURCE_TYPE_P59_METER_PROF      0x6UL
+#define CFA_RESOURCE_TYPE_P59_METER_PROF      0x7UL
 /* Meter */
-#define CFA_RESOURCE_TYPE_P59_METER           0x7UL
+#define CFA_RESOURCE_TYPE_P59_METER           0x8UL
 /* Meter */
-#define CFA_RESOURCE_TYPE_P59_MIRROR          0x8UL
+#define CFA_RESOURCE_TYPE_P59_MIRROR          0x9UL
 /* Source Properties TCAM */
-#define CFA_RESOURCE_TYPE_P59_SP_TCAM         0x9UL
+#define CFA_RESOURCE_TYPE_P59_SP_TCAM         0xaUL
 /* Exact Match Flexible Key Builder */
-#define CFA_RESOURCE_TYPE_P59_EM_FKB          0xaUL
+#define CFA_RESOURCE_TYPE_P59_EM_FKB          0xbUL
 /* Wildcard Flexible Key Builder */
-#define CFA_RESOURCE_TYPE_P59_WC_FKB          0xbUL
+#define CFA_RESOURCE_TYPE_P59_WC_FKB          0xcUL
 /* Table Scope */
-#define CFA_RESOURCE_TYPE_P59_TBL_SCOPE       0xcUL
+#define CFA_RESOURCE_TYPE_P59_TBL_SCOPE       0xdUL
 /* L2 Func */
-#define CFA_RESOURCE_TYPE_P59_L2_FUNC         0xdUL
+#define CFA_RESOURCE_TYPE_P59_L2_FUNC         0xeUL
 /* EPOCH */
-#define CFA_RESOURCE_TYPE_P59_EPOCH           0xeUL
+#define CFA_RESOURCE_TYPE_P59_EPOCH           0xfUL
 /* Metadata */
-#define CFA_RESOURCE_TYPE_P59_METADATA        0xfUL
+#define CFA_RESOURCE_TYPE_P59_METADATA        0x10UL
 /* Connection Tracking Rule TCAM */
-#define CFA_RESOURCE_TYPE_P59_CT_RULE_TCAM    0x10UL
+#define CFA_RESOURCE_TYPE_P59_CT_RULE_TCAM    0x11UL
 /* Range Profile */
-#define CFA_RESOURCE_TYPE_P59_RANGE_PROF      0x11UL
+#define CFA_RESOURCE_TYPE_P59_RANGE_PROF      0x12UL
 /* Range */
-#define CFA_RESOURCE_TYPE_P59_RANGE           0x12UL
+#define CFA_RESOURCE_TYPE_P59_RANGE           0x13UL
 /* Link Aggrigation */
-#define CFA_RESOURCE_TYPE_P59_LAG             0x13UL
+#define CFA_RESOURCE_TYPE_P59_LAG             0x14UL
 /* VEB TCAM */
-#define CFA_RESOURCE_TYPE_P59_VEB_TCAM        0x14UL
+#define CFA_RESOURCE_TYPE_P59_VEB_TCAM        0x15UL
 #define CFA_RESOURCE_TYPE_P59_LAST           CFA_RESOURCE_TYPE_P59_VEB_TCAM
 
 
@@ -105,30 +107,32 @@
 #define CFA_RESOURCE_TYPE_P58_FORMAT_4_ACTION 0x13UL
 /* L2 Context TCAM */
 #define CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM    0x14UL
+/* L2 Context REMAP */
+#define CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP   0x15UL
 /* Profile Func */
-#define CFA_RESOURCE_TYPE_P58_PROF_FUNC       0x15UL
+#define CFA_RESOURCE_TYPE_P58_PROF_FUNC       0x16UL
 /* Profile TCAM */
-#define CFA_RESOURCE_TYPE_P58_PROF_TCAM       0x16UL
+#define CFA_RESOURCE_TYPE_P58_PROF_TCAM       0x17UL
 /* Exact Match Profile Id */
-#define CFA_RESOURCE_TYPE_P58_EM_PROF_ID      0x17UL
+#define CFA_RESOURCE_TYPE_P58_EM_PROF_ID      0x18UL
 /* Wildcard Profile Id */
-#define CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID 0x18UL
+#define CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID 0x19UL
 /* Exact Match Record */
-#define CFA_RESOURCE_TYPE_P58_EM_REC          0x19UL
+#define CFA_RESOURCE_TYPE_P58_EM_REC          0x1aUL
 /* Wildcard TCAM */
-#define CFA_RESOURCE_TYPE_P58_WC_TCAM         0x1aUL
+#define CFA_RESOURCE_TYPE_P58_WC_TCAM         0x1bUL
 /* Meter profile */
-#define CFA_RESOURCE_TYPE_P58_METER_PROF      0x1bUL
+#define CFA_RESOURCE_TYPE_P58_METER_PROF      0x1cUL
 /* Meter */
-#define CFA_RESOURCE_TYPE_P58_MIRROR          0x1cUL
+#define CFA_RESOURCE_TYPE_P58_MIRROR          0x1dUL
 /* Source Property TCAM */
-#define CFA_RESOURCE_TYPE_P58_SP_TCAM         0x1dUL
+#define CFA_RESOURCE_TYPE_P58_SP_TCAM         0x1eUL
 /* Exact Match Flexible Key Builder */
-#define CFA_RESOURCE_TYPE_P58_EM_FKB          0x1eUL
+#define CFA_RESOURCE_TYPE_P58_EM_FKB          0x1fUL
 /* Wildcard Flexible Key Builder */
-#define CFA_RESOURCE_TYPE_P58_WC_FKB          0x1fUL
+#define CFA_RESOURCE_TYPE_P58_WC_FKB          0x20UL
 /* VEB TCAM */
-#define CFA_RESOURCE_TYPE_P58_VEB_TCAM        0x20UL
+#define CFA_RESOURCE_TYPE_P58_VEB_TCAM        0x21UL
 #define CFA_RESOURCE_TYPE_P58_LAST           CFA_RESOURCE_TYPE_P58_VEB_TCAM
 
 
@@ -176,26 +180,28 @@
 #define CFA_RESOURCE_TYPE_P45_FORMAT_4_ACTION 0x14UL
 /* L2 Context TCAM */
 #define CFA_RESOURCE_TYPE_P45_L2_CTXT_TCAM    0x15UL
+/* L2 Context REMAP */
+#define CFA_RESOURCE_TYPE_P45_L2_CTXT_REMAP   0x16UL
 /* Profile Func */
-#define CFA_RESOURCE_TYPE_P45_PROF_FUNC       0x16UL
+#define CFA_RESOURCE_TYPE_P45_PROF_FUNC       0x17UL
 /* Profile TCAM */
-#define CFA_RESOURCE_TYPE_P45_PROF_TCAM       0x17UL
+#define CFA_RESOURCE_TYPE_P45_PROF_TCAM       0x18UL
 /* Exact Match Profile Id */
-#define CFA_RESOURCE_TYPE_P45_EM_PROF_ID      0x18UL
+#define CFA_RESOURCE_TYPE_P45_EM_PROF_ID      0x19UL
 /* Exact Match Record */
-#define CFA_RESOURCE_TYPE_P45_EM_REC          0x19UL
+#define CFA_RESOURCE_TYPE_P45_EM_REC          0x1aUL
 /* Wildcard Profile Id */
-#define CFA_RESOURCE_TYPE_P45_WC_TCAM_PROF_ID 0x1aUL
+#define CFA_RESOURCE_TYPE_P45_WC_TCAM_PROF_ID 0x1bUL
 /* Wildcard TCAM */
-#define CFA_RESOURCE_TYPE_P45_WC_TCAM         0x1bUL
+#define CFA_RESOURCE_TYPE_P45_WC_TCAM         0x1cUL
 /* Meter profile */
-#define CFA_RESOURCE_TYPE_P45_METER_PROF      0x1cUL
+#define CFA_RESOURCE_TYPE_P45_METER_PROF      0x1dUL
 /* Meter */
-#define CFA_RESOURCE_TYPE_P45_MIRROR          0x1dUL
+#define CFA_RESOURCE_TYPE_P45_MIRROR          0x1eUL
 /* Source Property TCAM */
-#define CFA_RESOURCE_TYPE_P45_SP_TCAM         0x1eUL
+#define CFA_RESOURCE_TYPE_P45_SP_TCAM         0x1fUL
 /* VEB TCAM */
-#define CFA_RESOURCE_TYPE_P45_VEB_TCAM        0x1fUL
+#define CFA_RESOURCE_TYPE_P45_VEB_TCAM        0x20UL
 #define CFA_RESOURCE_TYPE_P45_LAST           CFA_RESOURCE_TYPE_P45_VEB_TCAM
 
 
@@ -243,24 +249,26 @@
 #define CFA_RESOURCE_TYPE_P4_FORMAT_4_ACTION 0x14UL
 /* L2 Context TCAM */
 #define CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM    0x15UL
+/* L2 Context REMAP */
+#define CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP   0x16UL
 /* Profile Func */
-#define CFA_RESOURCE_TYPE_P4_PROF_FUNC       0x16UL
+#define CFA_RESOURCE_TYPE_P4_PROF_FUNC       0x17UL
 /* Profile TCAM */
-#define CFA_RESOURCE_TYPE_P4_PROF_TCAM       0x17UL
+#define CFA_RESOURCE_TYPE_P4_PROF_TCAM       0x18UL
 /* Exact Match Profile Id */
-#define CFA_RESOURCE_TYPE_P4_EM_PROF_ID      0x18UL
+#define CFA_RESOURCE_TYPE_P4_EM_PROF_ID      0x19UL
 /* Exact Match Record */
-#define CFA_RESOURCE_TYPE_P4_EM_REC          0x19UL
+#define CFA_RESOURCE_TYPE_P4_EM_REC          0x1aUL
 /* Wildcard Profile Id */
-#define CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID 0x1aUL
+#define CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID 0x1bUL
 /* Wildcard TCAM */
-#define CFA_RESOURCE_TYPE_P4_WC_TCAM         0x1bUL
+#define CFA_RESOURCE_TYPE_P4_WC_TCAM         0x1cUL
 /* Meter profile */
-#define CFA_RESOURCE_TYPE_P4_METER_PROF      0x1cUL
+#define CFA_RESOURCE_TYPE_P4_METER_PROF      0x1dUL
 /* Meter */
-#define CFA_RESOURCE_TYPE_P4_MIRROR          0x1dUL
+#define CFA_RESOURCE_TYPE_P4_MIRROR          0x1eUL
 /* Source Property TCAM */
-#define CFA_RESOURCE_TYPE_P4_SP_TCAM         0x1eUL
+#define CFA_RESOURCE_TYPE_P4_SP_TCAM         0x1fUL
 #define CFA_RESOURCE_TYPE_P4_LAST           CFA_RESOURCE_TYPE_P4_SP_TCAM
 
 
drivers/net/bnxt/tf_core/tf_device_p4.h +1 -1
index 5cd02b298..235d81f96 100644
@@ -12,7 +12,7 @@
 #include "tf_rm_new.h"
 
 struct tf_rm_element_cfg tf_ident_p4[TF_IDENT_TYPE_MAX] = {
-	{ TF_RM_ELEM_CFG_PRIVATE, CFA_RESOURCE_TYPE_INVALID },
+	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP },
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_PROF_FUNC },
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID },
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_EM_PROF_ID },
Signature · 1 line
2.21.1 (Apple Git-122.3)
#177 lore raw

PATCH v4 20/51 net/bnxt: update RM with residual checker

In reply to Ajit Khaparde

From: Michael Wildt <[email protected]>

- Add residual checker to the TF Host RM as well as new RM APIs. On close it will scan the DB and check of any remaining elements. If found they will be logged and FW msg sent for FW to scrub that specific type of resources.
- Update the module bind to be aware of the module type, for each of the modules.
- Add additional type 2 string util functions.
- Fix the device naming to be in compliance with TF.
- Update the device unbind order as to assure TCAMs gets flushed first.
- Update the close functionality such that the session gets closed after the device is unbound.

---
 drivers/net/bnxt/tf_core/tf_device.c     |  53 +++--
 drivers/net/bnxt/tf_core/tf_device.h     |  25 +-
 drivers/net/bnxt/tf_core/tf_device_p4.h  |   1 -
 drivers/net/bnxt/tf_core/tf_identifier.c |  10 +-
 drivers/net/bnxt/tf_core/tf_msg.c        |  67 +++++-
 drivers/net/bnxt/tf_core/tf_msg.h        |   7 +
 drivers/net/bnxt/tf_core/tf_rm_new.c     | 287 +++++++++++++++++++++--
 drivers/net/bnxt/tf_core/tf_rm_new.h     |  45 +++-
 drivers/net/bnxt/tf_core/tf_session.c    |  58 +++--
 drivers/net/bnxt/tf_core/tf_tbl_type.c   |   5 +-
 drivers/net/bnxt/tf_core/tf_tcam.c       |   5 +-
 drivers/net/bnxt/tf_core/tf_tcam.h       |   4 +
 drivers/net/bnxt/tf_core/tf_util.c       |  55 ++++-
 drivers/net/bnxt/tf_core/tf_util.h       |  32 +++
 14 files changed, 561 insertions(+), 93 deletions(-)
drivers/net/bnxt/tf_core/tf_device.c +28 -25
index b474e8c25..441d0c678 100644
@@ -10,7 +10,7 @@
 struct tf;
 
 /* Forward declarations */
-static int dev_unbind_p4(struct tf *tfp);
+static int tf_dev_unbind_p4(struct tf *tfp);
 
 /**
  * Device specific bind function, WH+
@@ -32,10 +32,10 @@ static int dev_unbind_p4(struct tf *tfp);
  *   - (-EINVAL) on parameter or internal failure.
  */
 static int
-dev_bind_p4(struct tf *tfp,
-	    bool shadow_copy,
-	    struct tf_session_resources *resources,
-	    struct tf_dev_info *dev_handle)
+tf_dev_bind_p4(struct tf *tfp,
+	       bool shadow_copy,
+	       struct tf_session_resources *resources,
+	       struct tf_dev_info *dev_handle)
 {
 	int rc;
 	int frc;
@@ -93,7 +93,7 @@ dev_bind_p4(struct tf *tfp,
 
  fail:
 	/* Cleanup of already created modules */
-	frc = dev_unbind_p4(tfp);
+	frc = tf_dev_unbind_p4(tfp);
 	if (frc)
 		return frc;
 
@@ -111,7 +111,7 @@ dev_bind_p4(struct tf *tfp,
  *   - (-EINVAL) on failure.
  */
 static int
-dev_unbind_p4(struct tf *tfp)
+tf_dev_unbind_p4(struct tf *tfp)
 {
 	int rc = 0;
 	bool fail = false;
@@ -119,25 +119,28 @@ dev_unbind_p4(struct tf *tfp)
 	/* Unbind all the support modules. As this is only done on
 	 * close we only report errors as everything has to be cleaned
 	 * up regardless.
+	 *
+	 * In case of residuals TCAMs are cleaned up first as to
+	 * invalidate the pipeline in a clean manner.
 	 */
-	rc = tf_ident_unbind(tfp);
+	rc = tf_tcam_unbind(tfp);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
-			    "Device unbind failed, Identifier\n");
+			    "Device unbind failed, TCAM\n");
 		fail = true;
 	}
 
-	rc = tf_tbl_unbind(tfp);
+	rc = tf_ident_unbind(tfp);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
-			    "Device unbind failed, Table Type\n");
+			    "Device unbind failed, Identifier\n");
 		fail = true;
 	}
 
-	rc = tf_tcam_unbind(tfp);
+	rc = tf_tbl_unbind(tfp);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
-			    "Device unbind failed, TCAM\n");
+			    "Device unbind failed, Table Type\n");
 		fail = true;
 	}
 
@@ -148,18 +151,18 @@ dev_unbind_p4(struct tf *tfp)
 }
 
 int
-dev_bind(struct tf *tfp __rte_unused,
-	 enum tf_device_type type,
-	 bool shadow_copy,
-	 struct tf_session_resources *resources,
-	 struct tf_dev_info *dev_handle)
+tf_dev_bind(struct tf *tfp __rte_unused,
+	    enum tf_device_type type,
+	    bool shadow_copy,
+	    struct tf_session_resources *resources,
+	    struct tf_dev_info *dev_handle)
 {
 	switch (type) {
 	case TF_DEVICE_TYPE_WH:
-		return dev_bind_p4(tfp,
-				   shadow_copy,
-				   resources,
-				   dev_handle);
+		return tf_dev_bind_p4(tfp,
+				      shadow_copy,
+				      resources,
+				      dev_handle);
 	default:
 		TFP_DRV_LOG(ERR,
 			    "No such device\n");
@@ -168,12 +171,12 @@ dev_bind(struct tf *tfp __rte_unused,
 }
 
 int
-dev_unbind(struct tf *tfp,
-	   struct tf_dev_info *dev_handle)
+tf_dev_unbind(struct tf *tfp,
+	      struct tf_dev_info *dev_handle)
 {
 	switch (dev_handle->type) {
 	case TF_DEVICE_TYPE_WH:
-		return dev_unbind_p4(tfp);
+		return tf_dev_unbind_p4(tfp);
 	default:
 		TFP_DRV_LOG(ERR,
 			    "No such device\n");
drivers/net/bnxt/tf_core/tf_device.h +18 -7
index c31bf2357..c8feac55d 100644
@@ -14,6 +14,17 @@
 struct tf;
 struct tf_session;
 
+/**
+ *
+ */
+enum tf_device_module_type {
+	TF_DEVICE_MODULE_TYPE_IDENTIFIER,
+	TF_DEVICE_MODULE_TYPE_TABLE,
+	TF_DEVICE_MODULE_TYPE_TCAM,
+	TF_DEVICE_MODULE_TYPE_EM,
+	TF_DEVICE_MODULE_TYPE_MAX
+};
+
 /**
  * The Device module provides a general device template. A supported
  * device type should implement one or more of the listed function
@@ -60,11 +71,11 @@ struct tf_dev_info {
  *   - (-EINVAL) parameter failure.
  *   - (-ENODEV) no such device supported.
  */
-int dev_bind(struct tf *tfp,
-	     enum tf_device_type type,
-	     bool shadow_copy,
-	     struct tf_session_resources *resources,
-	     struct tf_dev_info *dev_handle);
+int tf_dev_bind(struct tf *tfp,
+		enum tf_device_type type,
+		bool shadow_copy,
+		struct tf_session_resources *resources,
+		struct tf_dev_info *dev_handle);
 
 /**
  * Device release handles cleanup of the device specific information.
@@ -80,8 +91,8 @@ int dev_bind(struct tf *tfp,
  *   - (-EINVAL) parameter failure.
  *   - (-ENODEV) no such device supported.
  */
-int dev_unbind(struct tf *tfp,
-	       struct tf_dev_info *dev_handle);
+int tf_dev_unbind(struct tf *tfp,
+		  struct tf_dev_info *dev_handle);
 
 /**
  * Truflow device specific function hooks structure
drivers/net/bnxt/tf_core/tf_device_p4.h +0 -1
index 235d81f96..411e21637 100644
@@ -77,5 +77,4 @@ struct tf_rm_element_cfg tf_tbl_p4[TF_TBL_TYPE_MAX] = {
 	/* CFA_RESOURCE_TYPE_P4_EXT */
 	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID }
 };
-
 #endif /* _TF_DEVICE_P4_H_ */
drivers/net/bnxt/tf_core/tf_identifier.c +6 -4
index ee07a6aea..b197bb271 100644
@@ -39,12 +39,12 @@ tf_ident_bind(struct tf *tfp,
 		return -EINVAL;
 	}
 
+	db_cfg.type = TF_DEVICE_MODULE_TYPE_IDENTIFIER;
 	db_cfg.num_elements = parms->num_elements;
+	db_cfg.cfg = parms->cfg;
 
 	for (i = 0; i < TF_DIR_MAX; i++) {
 		db_cfg.dir = i;
-		db_cfg.num_elements = parms->num_elements;
-		db_cfg.cfg = parms->cfg;
 		db_cfg.alloc_cnt = parms->resources->ident_cnt[i].cnt;
 		db_cfg.rm_db = &ident_db[i];
 		rc = tf_rm_create_db(tfp, &db_cfg);
@@ -86,8 +86,10 @@ tf_ident_unbind(struct tf *tfp __rte_unused)
 		fparms.dir = i;
 		fparms.rm_db = ident_db[i];
 		rc = tf_rm_free_db(tfp, &fparms);
-		if (rc)
-			return rc;
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "rm free failed on unbind\n");
+		}
 
 		ident_db[i] = NULL;
 	}
drivers/net/bnxt/tf_core/tf_msg.c +64 -3

79 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_msg.h +7 -0
index fb635f6dc..1ff1044e8 100644
@@ -181,6 +181,13 @@ int tf_msg_session_resc_alloc(struct tf *tfp,
 			      struct tf_rm_resc_req_entry *request,
 			      struct tf_rm_resc_entry *resv);
 
+/**
+ * Sends session resource flush request to TF Firmware
+ */
+int tf_msg_session_resc_flush(struct tf *tfp,
+			      enum tf_dir dir,
+			      uint16_t size,
+			      struct tf_rm_resc_entry *resv);
 /**
  * Sends EM internal insert request to Firmware
  */
drivers/net/bnxt/tf_core/tf_rm_new.c +273 -14

370 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_rm_new.h +42 -3

80 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_session.c +36 -22

82 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_tbl_type.c +3 -2
index 51f8f0740..bdf7d2089 100644
@@ -51,11 +51,12 @@ tf_tbl_bind(struct tf *tfp,
 	}
 
 	db_cfg.num_elements = parms->num_elements;
+	db_cfg.type = TF_DEVICE_MODULE_TYPE_TABLE;
+	db_cfg.num_elements = parms->num_elements;
+	db_cfg.cfg = parms->cfg;
 
 	for (i = 0; i < TF_DIR_MAX; i++) {
 		db_cfg.dir = i;
-		db_cfg.num_elements = parms->num_elements;
-		db_cfg.cfg = parms->cfg;
 		db_cfg.alloc_cnt = parms->resources->tbl_cnt[i].cnt;
 		db_cfg.rm_db = &tbl_db[i];
 		rc = tf_rm_create_db(tfp, &db_cfg);
drivers/net/bnxt/tf_core/tf_tcam.c +3 -2
index e0fac31f2..2f4441de8 100644
@@ -54,11 +54,12 @@ tf_tcam_bind(struct tf *tfp,
 	}
 
 	db_cfg.num_elements = parms->num_elements;
+	db_cfg.type = TF_DEVICE_MODULE_TYPE_TCAM;
+	db_cfg.num_elements = parms->num_elements;
+	db_cfg.cfg = parms->cfg;
 
 	for (i = 0; i < TF_DIR_MAX; i++) {
 		db_cfg.dir = i;
-		db_cfg.num_elements = parms->num_elements;
-		db_cfg.cfg = parms->cfg;
 		db_cfg.alloc_cnt = parms->resources->tcam_cnt[i].cnt;
 		db_cfg.rm_db = &tcam_db[i];
 		rc = tf_rm_create_db(tfp, &db_cfg);
drivers/net/bnxt/tf_core/tf_tcam.h +4 -0
index 67c3bcb49..5090dfd9f 100644
@@ -146,6 +146,10 @@ struct tf_tcam_set_parms {
 	 * [in] Type of object to set
 	 */
 	enum tf_tcam_tbl_type type;
+	/**
+	 * [in] Type of HCAPI
+	 */
+	uint16_t hcapi_type;
 	/**
 	 * [in] Entry index to write to
 	 */
drivers/net/bnxt/tf_core/tf_util.c +45 -10

88 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_util.h +32 -0
index ad8edaf30..c97e2a66a 100644
@@ -7,6 +7,7 @@
 #define _TF_UTIL_H_
 
 #include "tf_core.h"
+#include "tf_device.h"
 
 /**
  * Helper function converting direction to text string
@@ -63,4 +64,35 @@ const char *tf_tbl_type_2_str(enum tf_tbl_type tbl_type);
  */
 const char *tf_em_tbl_type_2_str(enum tf_em_tbl_type em_type);
 
+/**
+ * Helper function converting device module type and module type to
+ * text string.
+ *
+ * [in] dm_type
+ *   Device Module type
+ *
+ * [in] mod_type
+ *   Module specific type
+ *
+ * Returns:
+ *   Pointer to a char string holding the string for the EM type
+ */
+const char *tf_device_module_type_subtype_2_str
+					(enum tf_device_module_type dm_type,
+					 uint16_t mod_type);
+
+/**
+ * Helper function converting device module type to text string
+ *
+ * [in] dm_type
+ *   Device Module type
+ *
+ * [in] mod_type
+ *   Module specific type
+ *
+ * Returns:
+ *   Pointer to a char string holding the string for the EM type
+ */
+const char *tf_device_module_type_2_str(enum tf_device_module_type dm_type);
+
 #endif /* _TF_UTIL_H_ */
Signature · 1 line
2.21.1 (Apple Git-122.3)
#178 lore raw

PATCH v4 21/51 net/bnxt: support two level priority for TCAMs

In reply to Ajit Khaparde

From: Jay Ding <[email protected]>

Allow TCAM indexes to be allocated from top or bottom. If the priority is set to 0, allocate from the lowest tcam indexes i.e. from top. Any other value, allocate it from the highest tcam indexes i.e. from bottom.

---
 drivers/net/bnxt/tf_core/bitalloc.c  | 107 +++++++++++++++++++++++++++
 drivers/net/bnxt/tf_core/bitalloc.h  |   5 ++
 drivers/net/bnxt/tf_core/tf_rm_new.c |   9 ++-
 drivers/net/bnxt/tf_core/tf_rm_new.h |   8 ++
 drivers/net/bnxt/tf_core/tf_tcam.c   |   1 +
 5 files changed, 129 insertions(+), 1 deletion(-)
drivers/net/bnxt/tf_core/bitalloc.c +107 -0
index fb4df9a19..918cabf19 100644
@@ -7,6 +7,40 @@
 
 #define BITALLOC_MAX_LEVELS 6
 
+
+/* Finds the last bit set plus 1, equivalent to gcc __builtin_fls */
+static int
+ba_fls(bitalloc_word_t v)
+{
+	int c = 32;
+
+	if (!v)
+		return 0;
+
+	if (!(v & 0xFFFF0000u)) {
+		v <<= 16;
+		c -= 16;
+	}
+	if (!(v & 0xFF000000u)) {
+		v <<= 8;
+		c -= 8;
+	}
+	if (!(v & 0xF0000000u)) {
+		v <<= 4;
+		c -= 4;
+	}
+	if (!(v & 0xC0000000u)) {
+		v <<= 2;
+		c -= 2;
+	}
+	if (!(v & 0x80000000u)) {
+		v <<= 1;
+		c -= 1;
+	}
+
+	return c;
+}
+
 /* Finds the first bit set plus 1, equivalent to gcc __builtin_ffs */
 static int
 ba_ffs(bitalloc_word_t v)
@@ -120,6 +154,79 @@ ba_alloc(struct bitalloc *pool)
 	return ba_alloc_helper(pool, 0, 1, 32, 0, &clear);
 }
 
+/**
+ * Help function to alloc entry from highest available index
+ *
+ * Searching the pool from highest index for the empty entry.
+ *
+ * [in] pool
+ *   Pointer to the resource pool
+ *
+ * [in] offset
+ *   Offset of the storage in the pool
+ *
+ * [in] words
+ *   Number of words in this level
+ *
+ * [in] size
+ *   Number of entries in this level
+ *
+ * [in] index
+ *   Index of words that has the entry
+ *
+ * [in] clear
+ *   Indicate if a bit needs to be clear due to the entry is allocated
+ *
+ * Returns:
+ *     0 - Success
+ *    -1 - Failure
+ */
+static int
+ba_alloc_reverse_helper(struct bitalloc *pool,
+			int offset,
+			int words,
+			unsigned int size,
+			int index,
+			int *clear)
+{
+	bitalloc_word_t *storage = &pool->storage[offset];
+	int loc = ba_fls(storage[index]);
+	int r;
+
+	if (loc == 0)
+		return -1;
+
+	loc--;
+
+	if (pool->size > size) {
+		r = ba_alloc_reverse_helper(pool,
+					    offset + words + 1,
+					    storage[words],
+					    size * 32,
+					    index * 32 + loc,
+					    clear);
+	} else {
+		r = index * 32 + loc;
+		*clear = 1;
+		pool->free_count--;
+	}
+
+	if (*clear) {
+		storage[index] &= ~(1 << loc);
+		*clear = (storage[index] == 0);
+	}
+
+	return r;
+}
+
+int
+ba_alloc_reverse(struct bitalloc *pool)
+{
+	int clear = 0;
+
+	return ba_alloc_reverse_helper(pool, 0, 1, 32, 0, &clear);
+}
+
 static int
 ba_alloc_index_helper(struct bitalloc *pool,
 		      int              offset,
drivers/net/bnxt/tf_core/bitalloc.h +5 -0
index 563c8531a..2825bb37e 100644
@@ -72,6 +72,11 @@ int ba_init(struct bitalloc *pool, int size);
 int ba_alloc(struct bitalloc *pool);
 int ba_alloc_index(struct bitalloc *pool, int index);
 
+/**
+ * Returns -1 on failure, or index of allocated entry
+ */
+int ba_alloc_reverse(struct bitalloc *pool);
+
 /**
  * Query a particular index in a pool to check if its in use.
  *
drivers/net/bnxt/tf_core/tf_rm_new.c +8 -1
index 02b4b5c8f..de8f11955 100644
@@ -671,7 +671,14 @@ tf_rm_allocate(struct tf_rm_allocate_parms *parms)
 		return rc;
 	}
 
-	id = ba_alloc(rm_db->db[parms->db_index].pool);
+	/*
+	 * priority  0: allocate from top of the tcam i.e. high
+	 * priority !0: allocate index from bottom i.e lowest
+	 */
+	if (parms->priority)
+		id = ba_alloc_reverse(rm_db->db[parms->db_index].pool);
+	else
+		id = ba_alloc(rm_db->db[parms->db_index].pool);
 	if (id == BA_FAIL) {
 		rc = -ENOMEM;
 		TFP_DRV_LOG(ERR,
drivers/net/bnxt/tf_core/tf_rm_new.h +8 -0
index a40296ed2..5cb68892a 100644
@@ -185,6 +185,14 @@ struct tf_rm_allocate_parms {
 	 * i.e. Full Action Record offsets.
 	 */
 	uint32_t *index;
+	/**
+	 * [in] Priority, indicates the prority of the entry
+	 * priority  0: allocate from top of the tcam (from index 0
+	 *              or lowest available index)
+	 * priority !0: allocate from bottom of the tcam (from highest
+	 *              available index)
+	 */
+	uint32_t priority;
 };
 
 /**
drivers/net/bnxt/tf_core/tf_tcam.c +1 -0
index 2f4441de8..260fb15a6 100644
@@ -157,6 +157,7 @@ tf_tcam_alloc(struct tf *tfp,
 	/* Allocate requested element */
 	aparms.rm_db = tcam_db[parms->dir];
 	aparms.db_index = parms->type;
+	aparms.priority = parms->priority;
 	aparms.index = (uint32_t *)&parms->idx;
 	rc = tf_rm_allocate(&aparms);
 	if (rc) {
Signature · 1 line
2.21.1 (Apple Git-122.3)
#179 lore raw

PATCH v4 22/51 net/bnxt: support EM and TCAM lookup with table scope

In reply to Ajit Khaparde

From: Peter Spreadborough <[email protected]>

- Support for table scope within the EM module
- Support for host and system memory
- Update TCAM set/free.
- Replace TF device type by HCAPI RM type.
- Update TCAM set and free for HCAPI RM type

---
 drivers/net/bnxt/meson.build                  |    5 +-
 drivers/net/bnxt/tf_core/Makefile             |    5 +-
 drivers/net/bnxt/tf_core/cfa_resource_types.h |    8 +-
 drivers/net/bnxt/tf_core/hwrm_tf.h            |  864 +-----------
 drivers/net/bnxt/tf_core/tf_core.c            |  100 +-
 drivers/net/bnxt/tf_core/tf_device.c          |   50 +-
 drivers/net/bnxt/tf_core/tf_device.h          |   86 +-
 drivers/net/bnxt/tf_core/tf_device_p4.c       |   14 +-
 drivers/net/bnxt/tf_core/tf_device_p4.h       |   20 +-
 drivers/net/bnxt/tf_core/tf_em.c              |  360 -----
 drivers/net/bnxt/tf_core/tf_em.h              |  310 +++-
 drivers/net/bnxt/tf_core/tf_em_common.c       |  281 ++++
 drivers/net/bnxt/tf_core/tf_em_common.h       |  107 ++
 drivers/net/bnxt/tf_core/tf_em_host.c         | 1146 +++++++++++++++
 drivers/net/bnxt/tf_core/tf_em_internal.c     |  312 +++++
 drivers/net/bnxt/tf_core/tf_em_system.c       |  118 ++
 drivers/net/bnxt/tf_core/tf_msg.c             | 1248 ++++-------------
 drivers/net/bnxt/tf_core/tf_msg.h             |  233 +--
 drivers/net/bnxt/tf_core/tf_rm.c              |   89 +-
 drivers/net/bnxt/tf_core/tf_rm_new.c          |   40 +-
 drivers/net/bnxt/tf_core/tf_tbl.c             | 1134 ---------------
 drivers/net/bnxt/tf_core/tf_tbl_type.c        |   39 +-
 drivers/net/bnxt/tf_core/tf_tcam.c            |   25 +-
 drivers/net/bnxt/tf_core/tf_tcam.h            |    4 +
 drivers/net/bnxt/tf_core/tf_util.c            |    4 +-
 25 files changed, 3030 insertions(+), 3572 deletions(-)
 delete mode 100644 drivers/net/bnxt/tf_core/tf_em.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_em_common.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_em_common.h
 create mode 100644 drivers/net/bnxt/tf_core/tf_em_host.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_em_internal.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_em_system.c
drivers/net/bnxt/meson.build +4 -1
index 33e6ebd66..35038dc8b 100644
@@ -28,7 +28,10 @@ sources = files('bnxt_cpr.c',
 	'tf_core/tf_msg.c',
 	'tf_core/rand.c',
 	'tf_core/stack.c',
-	'tf_core/tf_em.c',
+        'tf_core/tf_em_common.c',
+        'tf_core/tf_em_host.c',
+        'tf_core/tf_em_internal.c',
+        'tf_core/tf_em_system.c',
 	'tf_core/tf_rm.c',
 	'tf_core/tf_tbl.c',
 	'tf_core/tfp.c',
drivers/net/bnxt/tf_core/Makefile +4 -1
index 5ed32f12a..f186741e4 100644
@@ -12,8 +12,11 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_core.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_rm.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tfp.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_msg.c
-SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_em.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_tbl.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_em_common.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_em_internal.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_em_host.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_em_system.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_session.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_device.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_device_p4.c
drivers/net/bnxt/tf_core/cfa_resource_types.h +6 -2
index 058d8cc88..6e79facec 100644
@@ -202,7 +202,9 @@
 #define CFA_RESOURCE_TYPE_P45_SP_TCAM         0x1fUL
 /* VEB TCAM */
 #define CFA_RESOURCE_TYPE_P45_VEB_TCAM        0x20UL
-#define CFA_RESOURCE_TYPE_P45_LAST           CFA_RESOURCE_TYPE_P45_VEB_TCAM
+/* Table Scope */
+#define CFA_RESOURCE_TYPE_P45_TBL_SCOPE       0x21UL
+#define CFA_RESOURCE_TYPE_P45_LAST           CFA_RESOURCE_TYPE_P45_TBL_SCOPE
 
 
 /* Multicast Group */
@@ -269,7 +271,9 @@
 #define CFA_RESOURCE_TYPE_P4_MIRROR          0x1eUL
 /* Source Property TCAM */
 #define CFA_RESOURCE_TYPE_P4_SP_TCAM         0x1fUL
-#define CFA_RESOURCE_TYPE_P4_LAST           CFA_RESOURCE_TYPE_P4_SP_TCAM
+/* Table Scope */
+#define CFA_RESOURCE_TYPE_P4_TBL_SCOPE       0x20UL
+#define CFA_RESOURCE_TYPE_P4_LAST           CFA_RESOURCE_TYPE_P4_TBL_SCOPE
 
 
 #endif /* _CFA_RESOURCE_TYPES_H_ */
drivers/net/bnxt/tf_core/hwrm_tf.h +1 -863

884 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_core.c +97 -3

121 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_device.c +46 -4

74 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_device.h +81 -5

109 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_device_p4.c +12 -2
index 9e332c594..127c655a6 100644
@@ -93,6 +93,12 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
 	.tf_dev_alloc_search_tcam = NULL,
 	.tf_dev_set_tcam = NULL,
 	.tf_dev_get_tcam = NULL,
+	.tf_dev_insert_int_em_entry = NULL,
+	.tf_dev_delete_int_em_entry = NULL,
+	.tf_dev_insert_ext_em_entry = NULL,
+	.tf_dev_delete_ext_em_entry = NULL,
+	.tf_dev_alloc_tbl_scope = NULL,
+	.tf_dev_free_tbl_scope = NULL,
 };
 
 /**
@@ -113,6 +119,10 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_alloc_search_tcam = NULL,
 	.tf_dev_set_tcam = tf_tcam_set,
 	.tf_dev_get_tcam = NULL,
-	.tf_dev_insert_em_entry = tf_em_insert_entry,
-	.tf_dev_delete_em_entry = tf_em_delete_entry,
+	.tf_dev_insert_int_em_entry = tf_em_insert_int_entry,
+	.tf_dev_delete_int_em_entry = tf_em_delete_int_entry,
+	.tf_dev_insert_ext_em_entry = tf_em_insert_ext_entry,
+	.tf_dev_delete_ext_em_entry = tf_em_delete_ext_entry,
+	.tf_dev_alloc_tbl_scope = tf_em_ext_common_alloc,
+	.tf_dev_free_tbl_scope = tf_em_ext_common_free,
 };
drivers/net/bnxt/tf_core/tf_device_p4.h +16 -4
index 411e21637..da6dd65a3 100644
@@ -36,13 +36,12 @@ struct tf_rm_element_cfg tf_tbl_p4[TF_TBL_TYPE_MAX] = {
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_MCG },
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_ENCAP_8B },
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_ENCAP_16B },
-	/* CFA_RESOURCE_TYPE_P4_SRAM_ENCAP_32B */
+	/* CFA_RESOURCE_TYPE_P4_ENCAP_32B */
 	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_ENCAP_64B },
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SP_MAC },
-	/* CFA_RESOURCE_TYPE_P4_SRAM_SP_SMAC_IPV4 */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
-	/* CFA_RESOURCE_TYPE_P4_SRAM_SP_SMAC_IPV6 */
+	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4 },
+	/* CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6 */
 	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_COUNTER_64B },
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_NAT_SPORT },
@@ -77,4 +76,17 @@ struct tf_rm_element_cfg tf_tbl_p4[TF_TBL_TYPE_MAX] = {
 	/* CFA_RESOURCE_TYPE_P4_EXT */
 	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID }
 };
+
+struct tf_rm_element_cfg tf_em_ext_p4[TF_EM_TBL_TYPE_MAX] = {
+	/* CFA_RESOURCE_TYPE_P4_EM_REC */
+	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_TBL_SCOPE },
+};
+
+struct tf_rm_element_cfg tf_em_int_p4[TF_EM_TBL_TYPE_MAX] = {
+	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_EM_REC },
+	/* CFA_RESOURCE_TYPE_P4_TBL_SCOPE */
+	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+};
+
 #endif /* _TF_DEVICE_P4_H_ */
drivers/net/bnxt/tf_core/tf_em.c deleted +0 -360

360 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_em.h +292 -18

339 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_em_common.c new file +281 -0

281 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_em_common.h new file +107 -0

107 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_em_host.c new file +1146 -0

625 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_em_internal.c new file +312 -0

312 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_em_system.c new file +118 -0

118 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_msg.c +251 -997

1,248 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_msg.h +154 -79

233 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_rm.c +2 -87

89 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_rm_new.c +37 -3
index de8f11955..2d9be654a 100644

Lines of this file are not shown. View the raw message.

drivers/net/bnxt/tf_core/tf_tbl.c +0 -1134

1,134 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_tbl_type.c +35 -4
index bdf7d2089..2f5af6060 100644

Lines of this file are not shown. View the raw message.

drivers/net/bnxt/tf_core/tf_tcam.c +22 -3
index 260fb15a6..a1761ad56 100644

Lines of this file are not shown. View the raw message.

drivers/net/bnxt/tf_core/tf_tcam.h +4 -0
index 5090dfd9f..ee5bacc09 100644

Lines of this file are not shown. View the raw message.

drivers/net/bnxt/tf_core/tf_util.c +2 -2
index 16c43eb67..5472a9aac 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.21.1 (Apple Git-122.3)

Part of the diff is not shown here. View the raw message.

#180 lore raw

PATCH v4 23/51 net/bnxt: update table get to use new design

In reply to Ajit Khaparde

From: Michael Wildt <[email protected]>

- Move bulk table get implementation to new Tbl Module design.
- Update messages for bulk table get
- Retrieve specified table element using bulk mechanism
- Remove deprecated resource definitions
- Update device type configuration for P4.
- Update RM DB HCAPI count check and fix EM internal and host code such that EM DBs can be created correctly.
- Update error logging to be info on unbind in the different modules.
- Move RTE RSVD out of tf_resources.h

---
 drivers/net/bnxt/hcapi/cfa_p40_tbl.h      |  250 ++
 drivers/net/bnxt/hcapi/hcapi_cfa.h        |    2 +
 drivers/net/bnxt/meson.build              |    3 +-
 drivers/net/bnxt/tf_core/Makefile         |    2 -
 drivers/net/bnxt/tf_core/tf_common.h      |   55 +-
 drivers/net/bnxt/tf_core/tf_core.c        |   86 +-
 drivers/net/bnxt/tf_core/tf_device.h      |   24 +-
 drivers/net/bnxt/tf_core/tf_device_p4.c   |    4 +-
 drivers/net/bnxt/tf_core/tf_device_p4.h   |    5 +-
 drivers/net/bnxt/tf_core/tf_em.h          |   88 +-
 drivers/net/bnxt/tf_core/tf_em_common.c   |   29 +-
 drivers/net/bnxt/tf_core/tf_em_internal.c |   59 +-
 drivers/net/bnxt/tf_core/tf_identifier.c  |   14 +-
 drivers/net/bnxt/tf_core/tf_msg.c         |   31 +-
 drivers/net/bnxt/tf_core/tf_msg.h         |    8 +-
 drivers/net/bnxt/tf_core/tf_resources.h   |  529 ---
 drivers/net/bnxt/tf_core/tf_rm.c          | 3695 ++++-----------------
 drivers/net/bnxt/tf_core/tf_rm.h          |  539 +--
 drivers/net/bnxt/tf_core/tf_rm_new.c      |  907 -----
 drivers/net/bnxt/tf_core/tf_rm_new.h      |  446 ---
 drivers/net/bnxt/tf_core/tf_session.h     |  214 +-
 drivers/net/bnxt/tf_core/tf_tbl.c         |  478 ++-
 drivers/net/bnxt/tf_core/tf_tbl.h         |  436 ++-
 drivers/net/bnxt/tf_core/tf_tbl_type.c    |  342 --
 drivers/net/bnxt/tf_core/tf_tbl_type.h    |  318 --
 drivers/net/bnxt/tf_core/tf_tcam.c        |   15 +-
 26 files changed, 2337 insertions(+), 6242 deletions(-)
 create mode 100644 drivers/net/bnxt/hcapi/cfa_p40_tbl.h
 delete mode 100644 drivers/net/bnxt/tf_core/tf_rm_new.c
 delete mode 100644 drivers/net/bnxt/tf_core/tf_rm_new.h
 delete mode 100644 drivers/net/bnxt/tf_core/tf_tbl_type.c
 delete mode 100644 drivers/net/bnxt/tf_core/tf_tbl_type.h
drivers/net/bnxt/hcapi/cfa_p40_tbl.h new file +250 -0
new file mode 100644
index 000000000..c30e4f49c
@@ -0,0 +1,250 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019-2020 Broadcom
+ * All rights reserved.
+ */
+/*
+ * Name:  cfa_p40_tbl.h
+ *
+ * Description: header for SWE based on Truflow
+ *
+ * Date:  12/16/19 17:18:12
+ *
+ * Note:  This file was originally generated by tflib_decode.py.
+ *        Remainder is hand coded due to lack of availability of xml for
+ *        addtional tables at this time (EEM Record and union fields)
+ *
+ **/
+#ifndef _CFA_P40_TBL_H_
+#define _CFA_P40_TBL_H_
+
+#include "cfa_p40_hw.h"
+
+#include "hcapi_cfa_defs.h"
+
+const struct hcapi_cfa_field cfa_p40_prof_l2_ctxt_tcam_layout[] = {
+	{CFA_P40_PROF_L2_CTXT_TCAM_VALID_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_VALID_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_KEY_TYPE_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_KEY_TYPE_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_TUN_HDR_TYPE_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_TUN_HDR_TYPE_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_T_L2_NUMTAGS_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_T_L2_NUMTAGS_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_L2_NUMTAGS_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_L2_NUMTAGS_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_MAC1_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_MAC1_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_T_OVID_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_T_OVID_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_T_IVID_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_T_IVID_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_SPARIF_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_SPARIF_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_SVIF_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_SVIF_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_MAC0_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_MAC0_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_OVID_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_OVID_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_IVID_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_IVID_NUM_BITS},
+};
+
+const struct hcapi_cfa_field cfa_p40_act_veb_tcam_layout[] = {
+	{CFA_P40_ACT_VEB_TCAM_VALID_BITPOS,
+	 CFA_P40_ACT_VEB_TCAM_VALID_NUM_BITS},
+	{CFA_P40_ACT_VEB_TCAM_RESERVED_BITPOS,
+	 CFA_P40_ACT_VEB_TCAM_RESERVED_NUM_BITS},
+	{CFA_P40_ACT_VEB_TCAM_PARIF_IN_BITPOS,
+	 CFA_P40_ACT_VEB_TCAM_PARIF_IN_NUM_BITS},
+	{CFA_P40_ACT_VEB_TCAM_NUM_VTAGS_BITPOS,
+	 CFA_P40_ACT_VEB_TCAM_NUM_VTAGS_NUM_BITS},
+	{CFA_P40_ACT_VEB_TCAM_MAC_BITPOS,
+	 CFA_P40_ACT_VEB_TCAM_MAC_NUM_BITS},
+	{CFA_P40_ACT_VEB_TCAM_OVID_BITPOS,
+	 CFA_P40_ACT_VEB_TCAM_OVID_NUM_BITS},
+	{CFA_P40_ACT_VEB_TCAM_IVID_BITPOS,
+	 CFA_P40_ACT_VEB_TCAM_IVID_NUM_BITS},
+};
+
+const struct hcapi_cfa_field cfa_p40_lkup_tcam_record_mem_layout[] = {
+	{CFA_P40_LKUP_TCAM_RECORD_MEM_VALID_BITPOS,
+	 CFA_P40_LKUP_TCAM_RECORD_MEM_VALID_NUM_BITS},
+	{CFA_P40_LKUP_TCAM_RECORD_MEM_ACT_REC_PTR_BITPOS,
+	 CFA_P40_LKUP_TCAM_RECORD_MEM_ACT_REC_PTR_NUM_BITS},
+	{CFA_P40_LKUP_TCAM_RECORD_MEM_STRENGTH_BITPOS,
+	 CFA_P40_LKUP_TCAM_RECORD_MEM_STRENGTH_NUM_BITS},
+};
+
+const struct hcapi_cfa_field cfa_p40_prof_ctxt_remap_mem_layout[] = {
+	{CFA_P40_PROF_CTXT_REMAP_MEM_TPID_ANTI_SPOOF_CTL_BITPOS,
+	 CFA_P40_PROF_CTXT_REMAP_MEM_TPID_ANTI_SPOOF_CTL_NUM_BITS},
+	{CFA_P40_PROF_CTXT_REMAP_MEM_PRI_ANTI_SPOOF_CTL_BITPOS,
+	 CFA_P40_PROF_CTXT_REMAP_MEM_PRI_ANTI_SPOOF_CTL_NUM_BITS},
+	{CFA_P40_PROF_CTXT_REMAP_MEM_BYP_SP_LKUP_BITPOS,
+	 CFA_P40_PROF_CTXT_REMAP_MEM_BYP_SP_LKUP_NUM_BITS},
+	{CFA_P40_PROF_CTXT_REMAP_MEM_SP_REC_PTR_BITPOS,
+	 CFA_P40_PROF_CTXT_REMAP_MEM_SP_REC_PTR_NUM_BITS},
+	{CFA_P40_PROF_CTXT_REMAP_MEM_BD_ACT_EN_BITPOS,
+	 CFA_P40_PROF_CTXT_REMAP_MEM_BD_ACT_EN_NUM_BITS},
+	{CFA_P40_PROF_CTXT_REMAP_MEM_DEFAULT_TPID_BITPOS,
+	 CFA_P40_PROF_CTXT_REMAP_MEM_DEFAULT_TPID_NUM_BITS},
+	{CFA_P40_PROF_CTXT_REMAP_MEM_ALLOWED_TPID_BITPOS,
+	 CFA_P40_PROF_CTXT_REMAP_MEM_ALLOWED_TPID_NUM_BITS},
+	{CFA_P40_PROF_CTXT_REMAP_MEM_DEFAULT_PRI_BITPOS,
+	 CFA_P40_PROF_CTXT_REMAP_MEM_DEFAULT_PRI_NUM_BITS},
+	{CFA_P40_PROF_CTXT_REMAP_MEM_ALLOWED_PRI_BITPOS,
+	 CFA_P40_PROF_CTXT_REMAP_MEM_ALLOWED_PRI_NUM_BITS},
+	{CFA_P40_PROF_CTXT_REMAP_MEM_PARIF_BITPOS,
+	 CFA_P40_PROF_CTXT_REMAP_MEM_PARIF_NUM_BITS},
+	{CFA_P40_PROF_CTXT_REMAP_MEM_BYP_LKUP_EN_BITPOS,
+	 CFA_P40_PROF_CTXT_REMAP_MEM_BYP_LKUP_EN_NUM_BITS},
+	/* Fields below not generated through automation */
+	{CFA_P40_PROF_CTXT_REMAP_MEM_PROF_VNIC_BITPOS,
+	 CFA_P40_PROF_CTXT_REMAP_MEM_PROF_VNIC_NUM_BITS},
+	{CFA_P40_PROF_CTXT_REMAP_MEM_PROF_FUNC_BITPOS,
+	 CFA_P40_PROF_CTXT_REMAP_MEM_PROF_FUNC_NUM_BITS},
+	{CFA_P40_PROF_CTXT_REMAP_MEM_L2_CTXT_BITPOS,
+	 CFA_P40_PROF_CTXT_REMAP_MEM_L2_CTXT_NUM_BITS},
+	{CFA_P40_PROF_CTXT_REMAP_MEM_ARP_BITPOS,
+	 CFA_P40_PROF_CTXT_REMAP_MEM_ARP_NUM_BITS},
+};
+
+const struct hcapi_cfa_field cfa_p40_prof_profile_tcam_remap_mem_layout[] = {
+	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_PL_BYP_LKUP_EN_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_PL_BYP_LKUP_EN_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_SEARCH_ENB_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_SEARCH_ENB_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_PROFILE_ID_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_PROFILE_ID_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_KEY_ID_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_KEY_ID_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_KEY_MASK_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_EM_KEY_MASK_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_SEARCH_ENB_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_SEARCH_ENB_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_PROFILE_ID_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_PROFILE_ID_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_KEY_ID_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_KEY_ID_NUM_BITS},
+};
+
+const struct hcapi_cfa_field cfa_p40_prof_profile_tcam_layout[] = {
+	{CFA_P40_PROF_PROFILE_TCAM_VALID_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_VALID_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_PKT_TYPE_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_PKT_TYPE_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_RECYCLE_CNT_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_RECYCLE_CNT_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_AGG_ERROR_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_AGG_ERROR_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_PROF_FUNC_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_PROF_FUNC_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_RESERVED_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_RESERVED_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_HREC_NEXT_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_HREC_NEXT_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TL2_HDR_VALID_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TL2_HDR_VALID_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TL2_HDR_TYPE_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TL2_HDR_TYPE_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TL2_UC_MC_BC_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TL2_UC_MC_BC_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TL2_VTAG_PRESENT_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TL2_VTAG_PRESENT_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TL2_TWO_VTAGS_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TL2_TWO_VTAGS_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TL3_VALID_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TL3_VALID_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TL3_ERROR_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TL3_ERROR_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TL3_HDR_TYPE_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TL3_HDR_TYPE_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TL3_HDR_ISIP_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TL3_HDR_ISIP_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TL3_IPV6_CMP_SRC_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TL3_IPV6_CMP_SRC_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TL3_IPV6_CMP_DEST_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TL3_IPV6_CMP_DEST_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_VALID_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_VALID_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_ERROR_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_ERROR_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_TYPE_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_TYPE_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_IS_UDP_TCP_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TL4_HDR_IS_UDP_TCP_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_VALID_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_VALID_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_ERR_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_ERR_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_TYPE_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_TYPE_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_FLAGS_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_TUN_HDR_FLAGS_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_L2_HDR_VALID_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_L2_HDR_VALID_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_L2_HDR_ERROR_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_L2_HDR_ERROR_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_L2_HDR_TYPE_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_L2_HDR_TYPE_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_L2_UC_MC_BC_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_L2_UC_MC_BC_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_L2_VTAG_PRESENT_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_L2_VTAG_PRESENT_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_L2_TWO_VTAGS_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_L2_TWO_VTAGS_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_L3_VALID_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_L3_VALID_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_L3_ERROR_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_L3_ERROR_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_L3_HDR_TYPE_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_L3_HDR_TYPE_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_L3_HDR_ISIP_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_L3_HDR_ISIP_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_L3_IPV6_CMP_SRC_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_L3_IPV6_CMP_SRC_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_L3_IPV6_CMP_DEST_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_L3_IPV6_CMP_DEST_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_L4_HDR_VALID_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_L4_HDR_VALID_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_L4_HDR_ERROR_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_L4_HDR_ERROR_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_L4_HDR_TYPE_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_L4_HDR_TYPE_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_L4_HDR_IS_UDP_TCP_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_L4_HDR_IS_UDP_TCP_NUM_BITS},
+};
+
+/**************************************************************************/
+/**
+ * Non-autogenerated fields
+ */
+
+const struct hcapi_cfa_field cfa_p40_eem_key_tbl_layout[] = {
+	{CFA_P40_EEM_KEY_TBL_VALID_BITPOS,
+	 CFA_P40_EEM_KEY_TBL_VALID_NUM_BITS},
+
+	{CFA_P40_EEM_KEY_TBL_L1_CACHEABLE_BITPOS,
+	 CFA_P40_EEM_KEY_TBL_L1_CACHEABLE_NUM_BITS},
+
+	{CFA_P40_EEM_KEY_TBL_STRENGTH_BITPOS,
+	 CFA_P40_EEM_KEY_TBL_STRENGTH_NUM_BITS},
+
+	{CFA_P40_EEM_KEY_TBL_KEY_SZ_BITPOS,
+	 CFA_P40_EEM_KEY_TBL_KEY_SZ_NUM_BITS},
+
+	{CFA_P40_EEM_KEY_TBL_REC_SZ_BITPOS,
+	 CFA_P40_EEM_KEY_TBL_REC_SZ_NUM_BITS},
+
+	{CFA_P40_EEM_KEY_TBL_ACT_REC_INT_BITPOS,
+	 CFA_P40_EEM_KEY_TBL_ACT_REC_INT_NUM_BITS},
+
+	{CFA_P40_EEM_KEY_TBL_EXT_FLOW_CTR_BITPOS,
+	 CFA_P40_EEM_KEY_TBL_EXT_FLOW_CTR_NUM_BITS},
+
+	{CFA_P40_EEM_KEY_TBL_AR_PTR_BITPOS,
+	 CFA_P40_EEM_KEY_TBL_AR_PTR_NUM_BITS},
+
+};
+#endif /* _CFA_P40_TBL_H_ */
drivers/net/bnxt/hcapi/hcapi_cfa.h +2 -0
index f60af4e56..7a67493bd 100644
@@ -243,6 +243,8 @@ int hcapi_cfa_p4_wc_tcam_hwop(struct hcapi_cfa_hwop *op,
 			       struct hcapi_cfa_data *obj_data);
 int hcapi_cfa_p4_wc_tcam_rec_hwop(struct hcapi_cfa_hwop *op,
 				   struct hcapi_cfa_data *obj_data);
+int hcapi_cfa_p4_mirror_hwop(struct hcapi_cfa_hwop *op,
+			     struct hcapi_cfa_data *mirror);
 #endif /* SUPPORT_CFA_HW_P4 */
 /**
  *  HCAPI CFA device HW operation function callback definition
drivers/net/bnxt/meson.build +1 -2
index 35038dc8b..7f3ec6204 100644
@@ -41,10 +41,9 @@ sources = files('bnxt_cpr.c',
 	'tf_core/tf_identifier.c',
 	'tf_core/tf_shadow_tbl.c',
 	'tf_core/tf_shadow_tcam.c',
-	'tf_core/tf_tbl_type.c',
 	'tf_core/tf_tcam.c',
 	'tf_core/tf_util.c',
-	'tf_core/tf_rm_new.c',
+	'tf_core/tf_rm.c',
 
 	'hcapi/hcapi_cfa_p4.c',
 
drivers/net/bnxt/tf_core/Makefile +0 -2
index f186741e4..9ba60e1c2 100644
@@ -23,10 +23,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_device_p4.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_identifier.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_shadow_tbl.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_shadow_tcam.c
-SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_tbl_type.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_tcam.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_util.c
-SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_rm_new.c
 
 SYMLINK-$(CONFIG_RTE_LIBRTE_BNXT_PMD)-include += tf_core/tf_core.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_BNXT_PMD)-include += tf_core/tf_project.h
drivers/net/bnxt/tf_core/tf_common.h +10 -45

74 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_core.c +79 -7

128 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_device.h +22 -2
index 2712d1039..93f3627d4 100644
@@ -8,7 +8,7 @@
 
 #include "tf_core.h"
 #include "tf_identifier.h"
-#include "tf_tbl_type.h"
+#include "tf_tbl.h"
 #include "tf_tcam.h"
 
 struct tf;
@@ -293,7 +293,27 @@ struct tf_dev_ops {
 	 *   - (-EINVAL) on failure.
 	 */
 	int (*tf_dev_get_tbl)(struct tf *tfp,
-			       struct tf_tbl_get_parms *parms);
+			      struct tf_tbl_get_parms *parms);
+
+	/**
+	 * Retrieves the specified table type element using 'bulk'
+	 * mechanism.
+	 *
+	 * This API retrieves the specified element data by invoking the
+	 * firmware.
+	 *
+	 * [in] tfp
+	 *   Pointer to TF handle
+	 *
+	 * [in] parms
+	 *   Pointer to table get bulk parameters
+	 *
+	 * Returns
+	 *   - (0) if successful.
+	 *   - (-EINVAL) on failure.
+	 */
+	int (*tf_dev_get_bulk_tbl)(struct tf *tfp,
+				   struct tf_tbl_get_bulk_parms *parms);
 
 	/**
 	 * Allocation of a tcam element.
drivers/net/bnxt/tf_core/tf_device_p4.c +3 -1
index 127c655a6..e3526672f 100644
@@ -8,7 +8,7 @@
 
 #include "tf_device.h"
 #include "tf_identifier.h"
-#include "tf_tbl_type.h"
+#include "tf_tbl.h"
 #include "tf_tcam.h"
 #include "tf_em.h"
 
@@ -88,6 +88,7 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
 	.tf_dev_alloc_search_tbl = NULL,
 	.tf_dev_set_tbl = NULL,
 	.tf_dev_get_tbl = NULL,
+	.tf_dev_get_bulk_tbl = NULL,
 	.tf_dev_alloc_tcam = NULL,
 	.tf_dev_free_tcam = NULL,
 	.tf_dev_alloc_search_tcam = NULL,
@@ -114,6 +115,7 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_alloc_search_tbl = NULL,
 	.tf_dev_set_tbl = tf_tbl_set,
 	.tf_dev_get_tbl = tf_tbl_get,
+	.tf_dev_get_bulk_tbl = tf_tbl_bulk_get,
 	.tf_dev_alloc_tcam = tf_tcam_alloc,
 	.tf_dev_free_tcam = tf_tcam_free,
 	.tf_dev_alloc_search_tcam = NULL,
drivers/net/bnxt/tf_core/tf_device_p4.h +2 -3
index da6dd65a3..473e4eae5 100644
@@ -9,7 +9,7 @@
 #include <cfa_resource_types.h>
 
 #include "tf_core.h"
-#include "tf_rm_new.h"
+#include "tf_rm.h"
 
 struct tf_rm_element_cfg tf_ident_p4[TF_IDENT_TYPE_MAX] = {
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP },
@@ -41,8 +41,7 @@ struct tf_rm_element_cfg tf_tbl_p4[TF_TBL_TYPE_MAX] = {
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_ENCAP_64B },
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SP_MAC },
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4 },
-	/* CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6 */
-	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6 },
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_COUNTER_64B },
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_NAT_SPORT },
 	{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_NAT_DPORT },
drivers/net/bnxt/tf_core/tf_em.h +84 -4

117 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_em_common.c +19 -10
index ba6aa7ac1..d0d80daeb 100644
@@ -194,12 +194,13 @@ tf_em_ext_common_bind(struct tf *tfp,
 	int rc;
 	int i;
 	struct tf_rm_create_db_parms db_cfg = { 0 };
+	uint8_t db_exists = 0;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
 	if (init) {
 		TFP_DRV_LOG(ERR,
-			    "Identifier already initialized\n");
+			    "EM Ext DB already initialized\n");
 		return -EINVAL;
 	}
 
@@ -210,19 +211,29 @@ tf_em_ext_common_bind(struct tf *tfp,
 	for (i = 0; i < TF_DIR_MAX; i++) {
 		db_cfg.dir = i;
 		db_cfg.alloc_cnt = parms->resources->em_cnt[i].cnt;
+
+		/* Check if we got any request to support EEM, if so
+		 * we build an EM Ext DB holding Table Scopes.
+		 */
+		if (db_cfg.alloc_cnt[TF_EM_TBL_TYPE_TBL_SCOPE] == 0)
+			continue;
+
 		db_cfg.rm_db = &eem_db[i];
 		rc = tf_rm_create_db(tfp, &db_cfg);
 		if (rc) {
 			TFP_DRV_LOG(ERR,
-				    "%s: EM DB creation failed\n",
+				    "%s: EM Ext DB creation failed\n",
 				    tf_dir_2_str(i));
 
 			return rc;
 		}
+		db_exists = 1;
 	}
 
-	mem_type = parms->mem_type;
-	init = 1;
+	if (db_exists) {
+		mem_type = parms->mem_type;
+		init = 1;
+	}
 
 	return 0;
 }
@@ -236,13 +247,11 @@ tf_em_ext_common_unbind(struct tf *tfp)
 
 	TF_CHECK_PARMS1(tfp);
 
-	/* Bail if nothing has been initialized done silent as to
-	 * allow for creation cleanup.
-	 */
+	/* Bail if nothing has been initialized */
 	if (!init) {
-		TFP_DRV_LOG(ERR,
-			    "No EM DBs created\n");
-		return -EINVAL;
+		TFP_DRV_LOG(INFO,
+			    "No EM Ext DBs created\n");
+		return 0;
 	}
 
 	for (i = 0; i < TF_DIR_MAX; i++) {
drivers/net/bnxt/tf_core/tf_em_internal.c +31 -28

87 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_identifier.c +6 -8
index b197bb271..211371081 100644
@@ -7,7 +7,7 @@
 
 #include "tf_identifier.h"
 #include "tf_common.h"
-#include "tf_rm_new.h"
+#include "tf_rm.h"
 #include "tf_util.h"
 #include "tfp.h"
 
@@ -35,7 +35,7 @@ tf_ident_bind(struct tf *tfp,
 
 	if (init) {
 		TFP_DRV_LOG(ERR,
-			    "Identifier already initialized\n");
+			    "Identifier DB already initialized\n");
 		return -EINVAL;
 	}
 
@@ -65,7 +65,7 @@ tf_ident_bind(struct tf *tfp,
 }
 
 int
-tf_ident_unbind(struct tf *tfp __rte_unused)
+tf_ident_unbind(struct tf *tfp)
 {
 	int rc;
 	int i;
@@ -73,13 +73,11 @@ tf_ident_unbind(struct tf *tfp __rte_unused)
 
 	TF_CHECK_PARMS1(tfp);
 
-	/* Bail if nothing has been initialized done silent as to
-	 * allow for creation cleanup.
-	 */
+	/* Bail if nothing has been initialized */
 	if (!init) {
-		TFP_DRV_LOG(ERR,
+		TFP_DRV_LOG(INFO,
 			    "No Identifier DBs created\n");
-		return -EINVAL;
+		return 0;
 	}
 
 	for (i = 0; i < TF_DIR_MAX; i++) {
drivers/net/bnxt/tf_core/tf_msg.c +23 -8
index d8b80bc84..02d8a4971 100644
@@ -871,26 +871,41 @@ tf_msg_get_tbl_entry(struct tf *tfp,
 
 int
 tf_msg_bulk_get_tbl_entry(struct tf *tfp,
-			  struct tf_bulk_get_tbl_entry_parms *params)
+			  enum tf_dir dir,
+			  uint16_t hcapi_type,
+			  uint32_t starting_idx,
+			  uint16_t num_entries,
+			  uint16_t entry_sz_in_bytes,
+			  uint64_t physical_mem_addr)
 {
 	int rc;
 	struct tfp_send_msg_parms parms = { 0 };
 	struct tf_tbl_type_bulk_get_input req = { 0 };
 	struct tf_tbl_type_bulk_get_output resp = { 0 };
-	struct tf_session *tfs = (struct tf_session *)(tfp->session->core_data);
+	struct tf_session *tfs;
 	int data_size = 0;
 
+	/* Retrieve the session information */
+	rc = tf_session_get_session(tfp, &tfs);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Failed to lookup session, rc:%s\n",
+			    tf_dir_2_str(dir),
+			    strerror(-rc));
+		return rc;
+	}
+
 	/* Populate the request */
 	req.fw_session_id =
 		tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
-	req.flags = tfp_cpu_to_le_16(params->dir);
-	req.type = tfp_cpu_to_le_32(params->type);
-	req.start_index = tfp_cpu_to_le_32(params->starting_idx);
-	req.num_entries = tfp_cpu_to_le_32(params->num_entries);
+	req.flags = tfp_cpu_to_le_16(dir);
+	req.type = tfp_cpu_to_le_32(hcapi_type);
+	req.start_index = tfp_cpu_to_le_32(starting_idx);
+	req.num_entries = tfp_cpu_to_le_32(num_entries);
 
-	data_size = params->num_entries * params->entry_sz_in_bytes;
+	data_size = num_entries * entry_sz_in_bytes;
 
-	req.host_addr = tfp_cpu_to_le_64(params->physical_mem_addr);
+	req.host_addr = tfp_cpu_to_le_64(physical_mem_addr);
 
 	MSG_PREP(parms,
 		 TF_KONG_MB,
drivers/net/bnxt/tf_core/tf_msg.h +6 -2
index 8e276d4c0..7432873d7 100644
@@ -11,7 +11,6 @@
 
 #include "tf_tbl.h"
 #include "tf_rm.h"
-#include "tf_rm_new.h"
 #include "tf_tcam.h"
 
 struct tf;
@@ -422,6 +421,11 @@ int tf_msg_get_tbl_entry(struct tf *tfp,
  *  0 on Success else internal Truflow error
  */
 int tf_msg_bulk_get_tbl_entry(struct tf *tfp,
-			  struct tf_bulk_get_tbl_entry_parms *parms);
+			      enum tf_dir dir,
+			      uint16_t hcapi_type,
+			      uint32_t starting_idx,
+			      uint16_t num_entries,
+			      uint16_t entry_sz_in_bytes,
+			      uint64_t physical_mem_addr);
 
 #endif  /* _TF_MSG_H_ */
drivers/net/bnxt/tf_core/tf_resources.h +0 -529

535 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_rm.c +720 -2975

1,534 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_rm.h +341 -198

539 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_rm_new.c deleted +0 -907

907 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_rm_new.h deleted +0 -446

446 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_session.h +3 -211

214 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_tbl.c +358 -120

478 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_tbl.h +369 -67

436 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_tbl_type.c deleted +0 -342

342 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_tbl_type.h deleted +0 -318

318 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_tcam.c +8 -7
index a1761ad56..fc047f8f8 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.21.1 (Apple Git-122.3)

Part of the diff is not shown here. View the raw message.

#181 lore raw

PATCH v4 24/51 net/bnxt: update RM to support HCAPI only

In reply to Ajit Khaparde

From: Peter Spreadborough <[email protected]>

- For the EM Module there is a need to only allocate the EM Records in HCAPI RM but the storage control is requested to be outside of the RM DB.
- Add TF_RM_ELEM_CFG_HCAPI_BA.
- Return error when the number of reserved entries for wc tcam is odd number in tf_tcam_bind.
- Remove em_pool from session
- Use RM provided start offset and size
- HCAPI returns entry index instead of row index for WC TCAM.
- Move resource type conversion to hrwm set/free tcam functions.

---
 drivers/net/bnxt/tf_core/tf_device_p4.c   |   2 +
 drivers/net/bnxt/tf_core/tf_device_p4.h   |  54 ++++-----
 drivers/net/bnxt/tf_core/tf_em_internal.c | 131 ++++++++++++++--------
 drivers/net/bnxt/tf_core/tf_msg.c         |   6 +-
 drivers/net/bnxt/tf_core/tf_rm.c          |  81 ++++++-------
 drivers/net/bnxt/tf_core/tf_rm.h          |  14 ++-
 drivers/net/bnxt/tf_core/tf_session.h     |   5 -
 drivers/net/bnxt/tf_core/tf_tcam.c        |  21 ++++
 8 files changed, 190 insertions(+), 124 deletions(-)
drivers/net/bnxt/tf_core/tf_device_p4.c +2 -0
index e3526672f..1eaf18212 100644
@@ -68,6 +68,8 @@ tf_dev_p4_get_tcam_slice_info(struct tf *tfp __rte_unused,
 		*num_slices_per_row = CFA_P4_WC_TCAM_SLICES_PER_ROW;
 		if (key_sz > *num_slices_per_row * CFA_P4_WC_TCAM_SLICE_SIZE)
 			return -ENOTSUP;
+
+		*num_slices_per_row = 1;
 	} else { /* for other type of tcam */
 		*num_slices_per_row = 1;
 	}
drivers/net/bnxt/tf_core/tf_device_p4.h +27 -27

79 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_em_internal.c +84 -47

272 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_msg.c +3 -3
index 02d8a4971..7fffb6baf 100644
@@ -857,12 +857,12 @@ tf_msg_get_tbl_entry(struct tf *tfp,
 		return rc;
 
 	/* Verify that we got enough buffer to return the requested data */
-	if (resp.size < size)
+	if (tfp_le_to_cpu_32(resp.size) != size)
 		return -EINVAL;
 
 	tfp_memcpy(data,
 		   &resp.data,
-		   resp.size);
+		   size);
 
 	return tfp_le_to_cpu_32(parms.tf_resp_code);
 }
@@ -919,7 +919,7 @@ tf_msg_bulk_get_tbl_entry(struct tf *tfp,
 		return rc;
 
 	/* Verify that we got enough buffer to return the requested data */
-	if (resp.size < data_size)
+	if (tfp_le_to_cpu_32(resp.size) != data_size)
 		return -EINVAL;
 
 	return tfp_le_to_cpu_32(parms.tf_resp_code);
drivers/net/bnxt/tf_core/tf_rm.c +43 -38

149 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_rm.h +10 -4
index 5cb68892a..f44fcca70 100644
@@ -56,12 +56,18 @@ struct tf_rm_new_entry {
  * ULP layer that is not controlled by HCAPI within the Firmware.
  */
 enum tf_rm_elem_cfg_type {
-	/** No configuration */
+	/**
+	 * No configuration
+	 */
 	TF_RM_ELEM_CFG_NULL,
-	/** HCAPI 'controlled', uses a Pool for internal storage */
+	/** HCAPI 'controlled', no RM storage thus the Device Module
+	 *  using the RM can chose to handle storage locally.
+	 */
 	TF_RM_ELEM_CFG_HCAPI,
-	/** Private thus not HCAPI 'controlled', creates a Pool for storage */
-	TF_RM_ELEM_CFG_PRIVATE,
+	/** HCAPI 'controlled', uses a Bit Allocator Pool for internal
+	 *  storage in the RM.
+	 */
+	TF_RM_ELEM_CFG_HCAPI_BA,
 	/**
 	 * Shared element thus it belongs to a shared FW Session and
 	 * is not controlled by the Host.
drivers/net/bnxt/tf_core/tf_session.h +0 -5
index e4472ed7f..ebee4db8c 100644
@@ -103,11 +103,6 @@ struct tf_session {
 
 	/** Table scope array */
 	struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
-
-	/**
-	 * EM Pools
-	 */
-	struct stack em_pool[TF_DIR_MAX];
 };
 
 /**
drivers/net/bnxt/tf_core/tf_tcam.c +21 -0
index fc047f8f8..d5bb4eec1 100644
@@ -43,6 +43,7 @@ tf_tcam_bind(struct tf *tfp,
 {
 	int rc;
 	int i;
+	struct tf_tcam_resources *tcam_cnt;
 	struct tf_rm_create_db_parms db_cfg = { 0 };
 
 	TF_CHECK_PARMS2(tfp, parms);
@@ -53,6 +54,14 @@ tf_tcam_bind(struct tf *tfp,
 		return -EINVAL;
 	}
 
+	tcam_cnt = parms->resources->tcam_cnt;
+	if ((tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] % 2) ||
+	    (tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] % 2)) {
+		TFP_DRV_LOG(ERR,
+			    "Number of WC TCAM entries cannot be odd num\n");
+		return -EINVAL;
+	}
+
 	db_cfg.type = TF_DEVICE_MODULE_TYPE_TCAM;
 	db_cfg.num_elements = parms->num_elements;
 	db_cfg.cfg = parms->cfg;
@@ -168,6 +177,18 @@ tf_tcam_alloc(struct tf *tfp,
 		return rc;
 	}
 
+	if (parms->type == TF_TCAM_TBL_TYPE_WC_TCAM &&
+	    (parms->idx % 2) != 0) {
+		rc = tf_rm_allocate(&aparms);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "%s: Failed tcam, type:%d\n",
+				    tf_dir_2_str(parms->dir),
+				    parms->type);
+			return rc;
+		}
+	}
+
 	parms->idx *= num_slice_per_row;
 
 	return 0;
Signature · 1 line
2.21.1 (Apple Git-122.3)
#182 lore raw

PATCH v4 25/51 net/bnxt: remove table scope from session

In reply to Ajit Khaparde

From: Peter Spreadborough <[email protected]>

- Remove table scope data from session. Added to EEM.
- Complete move to RM of table scope base and range.
- Fix some err messaging strings.
- Fix the tcam logging message.

---
 drivers/net/bnxt/tf_core/tf_core.c      |  2 +-
 drivers/net/bnxt/tf_core/tf_em.h        |  1 -
 drivers/net/bnxt/tf_core/tf_em_common.c | 16 +++++++----
 drivers/net/bnxt/tf_core/tf_em_common.h |  5 +---
 drivers/net/bnxt/tf_core/tf_em_host.c   | 38 ++++++++++---------------
 drivers/net/bnxt/tf_core/tf_em_system.c | 12 +++-----
 drivers/net/bnxt/tf_core/tf_session.h   |  3 --
 drivers/net/bnxt/tf_core/tf_tcam.c      |  6 ++--
 8 files changed, 35 insertions(+), 48 deletions(-)
drivers/net/bnxt/tf_core/tf_core.c +1 -1
index 8727900c4..6410843f6 100644
@@ -573,7 +573,7 @@ tf_free_tcam_entry(struct tf *tfp,
 	rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
-			    "%s: TCAM allocation failed, rc:%s\n",
+			    "%s: TCAM free failed, rc:%s\n",
 			    tf_dir_2_str(parms->dir),
 			    strerror(-rc));
 		return rc;
drivers/net/bnxt/tf_core/tf_em.h +0 -1
index 6bfcbd59e..617b07587 100644
@@ -9,7 +9,6 @@
 #include "tf_core.h"
 #include "tf_session.h"
 
-#define TF_HACK_TBL_SCOPE_BASE 68
 #define SUPPORT_CFA_HW_P4 1
 #define SUPPORT_CFA_HW_P58 0
 #define SUPPORT_CFA_HW_P59 0
drivers/net/bnxt/tf_core/tf_em_common.c +10 -6
index d0d80daeb..e31a63b46 100644
@@ -29,6 +29,8 @@
  */
 void *eem_db[TF_DIR_MAX];
 
+#define TF_EEM_DB_TBL_SCOPE 1
+
 /**
  * Init flag, set on bind and cleared on unbind
  */
@@ -39,10 +41,12 @@ static uint8_t init;
  */
 static enum tf_mem_type mem_type;
 
+/** Table scope array */
+struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
+
 /* API defined in tf_em.h */
 struct tf_tbl_scope_cb *
-tbl_scope_cb_find(struct tf_session *session,
-		  uint32_t tbl_scope_id)
+tbl_scope_cb_find(uint32_t tbl_scope_id)
 {
 	int i;
 	struct tf_rm_is_allocated_parms parms;
@@ -50,8 +54,8 @@ tbl_scope_cb_find(struct tf_session *session,
 
 	/* Check that id is valid */
 	parms.rm_db = eem_db[TF_DIR_RX];
-	parms.db_index = 1/**** TYPE TABLE-SCOPE??? ****/;
-	parms.index = tbl_scope_id + TF_HACK_TBL_SCOPE_BASE;
+	parms.db_index = TF_EEM_DB_TBL_SCOPE;
+	parms.index = tbl_scope_id;
 	parms.allocated = &allocated;
 
 	i = tf_rm_is_allocated(&parms);
@@ -60,8 +64,8 @@ tbl_scope_cb_find(struct tf_session *session,
 		return NULL;
 
 	for (i = 0; i < TF_NUM_TBL_SCOPE; i++) {
-		if (session->tbl_scopes[i].tbl_scope_id == tbl_scope_id)
-			return &session->tbl_scopes[i];
+		if (tbl_scopes[i].tbl_scope_id == tbl_scope_id)
+			return &tbl_scopes[i];
 	}
 
 	return NULL;
drivers/net/bnxt/tf_core/tf_em_common.h +1 -4
index 45699a7c3..bf01df9b8 100644
@@ -14,8 +14,6 @@
  * Function to search for table scope control block structure
  * with specified table scope ID.
  *
- * [in] session
- *   Session to use for the search of the table scope control block
  * [in] tbl_scope_id
  *   Table scope ID to search for
  *
@@ -23,8 +21,7 @@
  *  Pointer to the found table scope control block struct or NULL if
  *   table scope control block struct not found
  */
-struct tf_tbl_scope_cb *tbl_scope_cb_find(struct tf_session *session,
-					  uint32_t tbl_scope_id);
+struct tf_tbl_scope_cb *tbl_scope_cb_find(uint32_t tbl_scope_id);
 
 /**
  * Create and initialize a stack to use for action entries
drivers/net/bnxt/tf_core/tf_em_host.c +15 -23
index 8be39afdd..543edb54a 100644
@@ -48,6 +48,9 @@
  * EM DBs.
  */
 extern void *eem_db[TF_DIR_MAX];
+#define TF_EEM_DB_TBL_SCOPE 1
+
+extern struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
 
 /**
  * Function to free a page table
@@ -934,14 +937,12 @@ tf_delete_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
  *    -EINVAL - Error
  */
 int
-tf_em_insert_ext_entry(struct tf *tfp,
+tf_em_insert_ext_entry(struct tf *tfp __rte_unused,
 		       struct tf_insert_em_entry_parms *parms)
 {
 	struct tf_tbl_scope_cb *tbl_scope_cb;
 
-	tbl_scope_cb =
-	tbl_scope_cb_find((struct tf_session *)(tfp->session->core_data),
-			  parms->tbl_scope_id);
+	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
 	if (tbl_scope_cb == NULL) {
 		TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n");
 		return -EINVAL;
@@ -957,14 +958,12 @@ tf_em_insert_ext_entry(struct tf *tfp,
  *    -EINVAL - Error
  */
 int
-tf_em_delete_ext_entry(struct tf *tfp,
+tf_em_delete_ext_entry(struct tf *tfp __rte_unused,
 		       struct tf_delete_em_entry_parms *parms)
 {
 	struct tf_tbl_scope_cb *tbl_scope_cb;
 
-	tbl_scope_cb =
-	tbl_scope_cb_find((struct tf_session *)(tfp->session->core_data),
-			  parms->tbl_scope_id);
+	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
 	if (tbl_scope_cb == NULL) {
 		TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n");
 		return -EINVAL;
@@ -981,16 +980,13 @@ tf_em_ext_host_alloc(struct tf *tfp,
 	enum tf_dir dir;
 	struct tf_tbl_scope_cb *tbl_scope_cb;
 	struct hcapi_cfa_em_table *em_tables;
-	struct tf_session *session;
 	struct tf_free_tbl_scope_parms free_parms;
 	struct tf_rm_allocate_parms aparms = { 0 };
 	struct tf_rm_free_parms fparms = { 0 };
 
-	session = (struct tf_session *)tfp->session->core_data;
-
 	/* Get Table Scope control block from the session pool */
 	aparms.rm_db = eem_db[TF_DIR_RX];
-	aparms.db_index = 1/**** TYPE TABLE-SCOPE??? ****/;
+	aparms.db_index = TF_EEM_DB_TBL_SCOPE;
 	aparms.index = (uint32_t *)&parms->tbl_scope_id;
 	rc = tf_rm_allocate(&aparms);
 	if (rc) {
@@ -999,8 +995,7 @@ tf_em_ext_host_alloc(struct tf *tfp,
 		return rc;
 	}
 
-	parms->tbl_scope_id -= TF_HACK_TBL_SCOPE_BASE;
-	tbl_scope_cb = &session->tbl_scopes[parms->tbl_scope_id];
+	tbl_scope_cb = &tbl_scopes[parms->tbl_scope_id];
 	tbl_scope_cb->index = parms->tbl_scope_id;
 	tbl_scope_cb->tbl_scope_id = parms->tbl_scope_id;
 
@@ -1092,8 +1087,8 @@ tf_em_ext_host_alloc(struct tf *tfp,
 cleanup:
 	/* Free Table control block */
 	fparms.rm_db = eem_db[TF_DIR_RX];
-	fparms.db_index = 1/**** TYPE TABLE-SCOPE??? ****/;
-	fparms.index = parms->tbl_scope_id + TF_HACK_TBL_SCOPE_BASE;
+	fparms.db_index = TF_EEM_DB_TBL_SCOPE;
+	fparms.index = parms->tbl_scope_id;
 	tf_rm_free(&fparms);
 	return -EINVAL;
 }
@@ -1105,13 +1100,9 @@ tf_em_ext_host_free(struct tf *tfp,
 	int rc = 0;
 	enum tf_dir  dir;
 	struct tf_tbl_scope_cb *tbl_scope_cb;
-	struct tf_session *session;
 	struct tf_rm_free_parms aparms = { 0 };
 
-	session = (struct tf_session *)(tfp->session->core_data);
-
-	tbl_scope_cb = tbl_scope_cb_find(session,
-					 parms->tbl_scope_id);
+	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
 
 	if (tbl_scope_cb == NULL) {
 		TFP_DRV_LOG(ERR, "Table scope error\n");
@@ -1120,8 +1111,8 @@ tf_em_ext_host_free(struct tf *tfp,
 
 	/* Free Table control block */
 	aparms.rm_db = eem_db[TF_DIR_RX];
-	aparms.db_index = 1/**** TYPE TABLE-SCOPE??? ****/;
-	aparms.index = parms->tbl_scope_id + TF_HACK_TBL_SCOPE_BASE;
+	aparms.db_index = TF_EEM_DB_TBL_SCOPE;
+	aparms.index = parms->tbl_scope_id;
 	rc = tf_rm_free(&aparms);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
@@ -1142,5 +1133,6 @@ tf_em_ext_host_free(struct tf *tfp,
 		tf_em_ctx_unreg(tfp, tbl_scope_cb, dir);
 	}
 
+	tbl_scopes[parms->tbl_scope_id].tbl_scope_id = -1;
 	return rc;
 }
drivers/net/bnxt/tf_core/tf_em_system.c +4 -8
index ee18a0c70..6dd115470 100644
@@ -63,14 +63,12 @@ tf_delete_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb __rte_unused,
  *    -EINVAL - Error
  */
 int
-tf_em_insert_ext_sys_entry(struct tf *tfp,
+tf_em_insert_ext_sys_entry(struct tf *tfp __rte_unused,
 			   struct tf_insert_em_entry_parms *parms)
 {
 	struct tf_tbl_scope_cb *tbl_scope_cb;
 
-	tbl_scope_cb = tbl_scope_cb_find
-		((struct tf_session *)(tfp->session->core_data),
-		parms->tbl_scope_id);
+	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
 	if (tbl_scope_cb == NULL) {
 		TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n");
 		return -EINVAL;
@@ -87,14 +85,12 @@ tf_em_insert_ext_sys_entry(struct tf *tfp,
  *    -EINVAL - Error
  */
 int
-tf_em_delete_ext_sys_entry(struct tf *tfp,
+tf_em_delete_ext_sys_entry(struct tf *tfp __rte_unused,
 			   struct tf_delete_em_entry_parms *parms)
 {
 	struct tf_tbl_scope_cb *tbl_scope_cb;
 
-	tbl_scope_cb = tbl_scope_cb_find
-		((struct tf_session *)(tfp->session->core_data),
-		parms->tbl_scope_id);
+	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
 	if (tbl_scope_cb == NULL) {
 		TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n");
 		return -EINVAL;
drivers/net/bnxt/tf_core/tf_session.h +0 -3
index ebee4db8c..a303fde51 100644
@@ -100,9 +100,6 @@ struct tf_session {
 
 	/** Device handle */
 	struct tf_dev_info dev;
-
-	/** Table scope array */
-	struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
 };
 
 /**
drivers/net/bnxt/tf_core/tf_tcam.c +4 -2
index d5bb4eec1..b67159a54 100644
@@ -287,7 +287,8 @@ tf_tcam_free(struct tf *tfp,
 	rc = tf_msg_tcam_entry_free(tfp, parms);
 	if (rc) {
 		/* Log error */
-		TFP_DRV_LOG(ERR, "%s: %s: Entry %d free failed with err %s",
+		TFP_DRV_LOG(ERR,
+			    "%s: %s: Entry %d free failed, rc:%s\n",
 			    tf_dir_2_str(parms->dir),
 			    tf_tcam_tbl_2_str(parms->type),
 			    parms->idx,
@@ -382,7 +383,8 @@ tf_tcam_set(struct tf *tfp __rte_unused,
 	rc = tf_msg_tcam_entry_set(tfp, parms);
 	if (rc) {
 		/* Log error */
-		TFP_DRV_LOG(ERR, "%s: %s: Entry %d free failed with err %s",
+		TFP_DRV_LOG(ERR,
+			    "%s: %s: Entry %d set failed, rc:%s",
 			    tf_dir_2_str(parms->dir),
 			    tf_tcam_tbl_2_str(parms->type),
 			    parms->idx,
Signature · 1 line
2.21.1 (Apple Git-122.3)
#183 lore raw

PATCH v4 26/51 net/bnxt: add external action alloc and free

In reply to Ajit Khaparde

From: Jay Ding <[email protected]>

- Link external action alloc and free to new hcapi interface
- Add parameter range checking
- Fix issues with index allocation check

---
 drivers/net/bnxt/tf_core/tf_core.c       | 163 ++++++++++++++++-------
 drivers/net/bnxt/tf_core/tf_core.h       |   4 -
 drivers/net/bnxt/tf_core/tf_device.h     |  58 ++++++++
 drivers/net/bnxt/tf_core/tf_device_p4.c  |   6 +
 drivers/net/bnxt/tf_core/tf_device_p4.h  |   2 -
 drivers/net/bnxt/tf_core/tf_em.h         |  95 +++++++++++++
 drivers/net/bnxt/tf_core/tf_em_common.c  | 120 ++++++++++++++++-
 drivers/net/bnxt/tf_core/tf_em_host.c    |  80 ++++++++++-
 drivers/net/bnxt/tf_core/tf_em_system.c  |   6 +
 drivers/net/bnxt/tf_core/tf_identifier.c |   4 +-
 drivers/net/bnxt/tf_core/tf_rm.h         |   5 +
 drivers/net/bnxt/tf_core/tf_tbl.c        |  10 +-
 drivers/net/bnxt/tf_core/tf_tbl.h        |  12 ++
 drivers/net/bnxt/tf_core/tf_tcam.c       |   8 +-
 drivers/net/bnxt/tf_core/tf_util.c       |   4 -
 15 files changed, 499 insertions(+), 78 deletions(-)
drivers/net/bnxt/tf_core/tf_core.c +115 -48
index 6410843f6..45accb0ab 100644
@@ -617,25 +617,48 @@ tf_alloc_tbl_entry(struct tf *tfp,
 		return rc;
 	}
 
-	if (dev->ops->tf_dev_alloc_tbl == NULL) {
-		rc = -EOPNOTSUPP;
-		TFP_DRV_LOG(ERR,
-			    "%s: Operation not supported, rc:%s\n",
-			    tf_dir_2_str(parms->dir),
-			    strerror(-rc));
-		return -EOPNOTSUPP;
-	}
-
 	aparms.dir = parms->dir;
 	aparms.type = parms->type;
 	aparms.idx = &idx;
-	rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "%s: Table allocation failed, rc:%s\n",
-			    tf_dir_2_str(parms->dir),
-			    strerror(-rc));
-		return rc;
+	aparms.tbl_scope_id = parms->tbl_scope_id;
+
+	if (parms->type == TF_TBL_TYPE_EXT) {
+		if (dev->ops->tf_dev_alloc_ext_tbl == NULL) {
+			rc = -EOPNOTSUPP;
+			TFP_DRV_LOG(ERR,
+				    "%s: Operation not supported, rc:%s\n",
+				    tf_dir_2_str(parms->dir),
+				    strerror(-rc));
+			return -EOPNOTSUPP;
+		}
+
+		rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "%s: External table allocation failed, rc:%s\n",
+				    tf_dir_2_str(parms->dir),
+				    strerror(-rc));
+			return rc;
+		}
+
+	} else {
+		if (dev->ops->tf_dev_alloc_tbl == NULL) {
+			rc = -EOPNOTSUPP;
+			TFP_DRV_LOG(ERR,
+				    "%s: Operation not supported, rc:%s\n",
+				    tf_dir_2_str(parms->dir),
+				    strerror(-rc));
+			return -EOPNOTSUPP;
+		}
+
+		rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "%s: Table allocation failed, rc:%s\n",
+				    tf_dir_2_str(parms->dir),
+				    strerror(-rc));
+			return rc;
+		}
 	}
 
 	parms->idx = idx;
@@ -677,25 +700,47 @@ tf_free_tbl_entry(struct tf *tfp,
 		return rc;
 	}
 
-	if (dev->ops->tf_dev_free_tbl == NULL) {
-		rc = -EOPNOTSUPP;
-		TFP_DRV_LOG(ERR,
-			    "%s: Operation not supported, rc:%s\n",
-			    tf_dir_2_str(parms->dir),
-			    strerror(-rc));
-		return -EOPNOTSUPP;
-	}
-
 	fparms.dir = parms->dir;
 	fparms.type = parms->type;
 	fparms.idx = parms->idx;
-	rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "%s: Table free failed, rc:%s\n",
-			    tf_dir_2_str(parms->dir),
-			    strerror(-rc));
-		return rc;
+	fparms.tbl_scope_id = parms->tbl_scope_id;
+
+	if (parms->type == TF_TBL_TYPE_EXT) {
+		if (dev->ops->tf_dev_free_ext_tbl == NULL) {
+			rc = -EOPNOTSUPP;
+			TFP_DRV_LOG(ERR,
+				    "%s: Operation not supported, rc:%s\n",
+				    tf_dir_2_str(parms->dir),
+				    strerror(-rc));
+			return -EOPNOTSUPP;
+		}
+
+		rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "%s: Table free failed, rc:%s\n",
+				    tf_dir_2_str(parms->dir),
+				    strerror(-rc));
+			return rc;
+		}
+	} else {
+		if (dev->ops->tf_dev_free_tbl == NULL) {
+			rc = -EOPNOTSUPP;
+			TFP_DRV_LOG(ERR,
+				    "%s: Operation not supported, rc:%s\n",
+				    tf_dir_2_str(parms->dir),
+				    strerror(-rc));
+			return -EOPNOTSUPP;
+		}
+
+		rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "%s: Table free failed, rc:%s\n",
+				    tf_dir_2_str(parms->dir),
+				    strerror(-rc));
+			return rc;
+		}
 	}
 
 	return 0;
@@ -735,27 +780,49 @@ tf_set_tbl_entry(struct tf *tfp,
 		return rc;
 	}
 
-	if (dev->ops->tf_dev_set_tbl == NULL) {
-		rc = -EOPNOTSUPP;
-		TFP_DRV_LOG(ERR,
-			    "%s: Operation not supported, rc:%s\n",
-			    tf_dir_2_str(parms->dir),
-			    strerror(-rc));
-		return -EOPNOTSUPP;
-	}
-
 	sparms.dir = parms->dir;
 	sparms.type = parms->type;
 	sparms.data = parms->data;
 	sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
 	sparms.idx = parms->idx;
-	rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "%s: Table set failed, rc:%s\n",
-			    tf_dir_2_str(parms->dir),
-			    strerror(-rc));
-		return rc;
+	sparms.tbl_scope_id = parms->tbl_scope_id;
+
+	if (parms->type == TF_TBL_TYPE_EXT) {
+		if (dev->ops->tf_dev_set_ext_tbl == NULL) {
+			rc = -EOPNOTSUPP;
+			TFP_DRV_LOG(ERR,
+				    "%s: Operation not supported, rc:%s\n",
+				    tf_dir_2_str(parms->dir),
+				    strerror(-rc));
+			return -EOPNOTSUPP;
+		}
+
+		rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "%s: Table set failed, rc:%s\n",
+				    tf_dir_2_str(parms->dir),
+				    strerror(-rc));
+			return rc;
+		}
+	} else {
+		if (dev->ops->tf_dev_set_tbl == NULL) {
+			rc = -EOPNOTSUPP;
+			TFP_DRV_LOG(ERR,
+				    "%s: Operation not supported, rc:%s\n",
+				    tf_dir_2_str(parms->dir),
+				    strerror(-rc));
+			return -EOPNOTSUPP;
+		}
+
+		rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
+		if (rc) {
+			TFP_DRV_LOG(ERR,
+				    "%s: Table set failed, rc:%s\n",
+				    tf_dir_2_str(parms->dir),
+				    strerror(-rc));
+			return rc;
+		}
 	}
 
 	return rc;
drivers/net/bnxt/tf_core/tf_core.h +0 -4
index a7a7bd38a..e898f19a0 100644
@@ -211,10 +211,6 @@ enum tf_tbl_type {
 	TF_TBL_TYPE_ACT_MODIFY_IPV4_SRC,
 	/** Wh+/SR Action _Modify L4 Dest Port */
 	TF_TBL_TYPE_ACT_MODIFY_IPV4_DEST,
-	/** Action Modify IPv6 Source */
-	TF_TBL_TYPE_ACT_MODIFY_IPV6_SRC,
-	/** Action Modify IPv6 Destination */
-	TF_TBL_TYPE_ACT_MODIFY_IPV6_DEST,
 	/** Meter Profiles */
 	TF_TBL_TYPE_METER_PROF,
 	/** Meter Instance */
drivers/net/bnxt/tf_core/tf_device.h +58 -0

76 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_device_p4.c +6 -0
index 1eaf18212..9a3230787 100644
@@ -85,10 +85,13 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
 	.tf_dev_get_tcam_slice_info = tf_dev_p4_get_tcam_slice_info,
 	.tf_dev_alloc_ident = NULL,
 	.tf_dev_free_ident = NULL,
+	.tf_dev_alloc_ext_tbl = NULL,
 	.tf_dev_alloc_tbl = NULL,
+	.tf_dev_free_ext_tbl = NULL,
 	.tf_dev_free_tbl = NULL,
 	.tf_dev_alloc_search_tbl = NULL,
 	.tf_dev_set_tbl = NULL,
+	.tf_dev_set_ext_tbl = NULL,
 	.tf_dev_get_tbl = NULL,
 	.tf_dev_get_bulk_tbl = NULL,
 	.tf_dev_alloc_tcam = NULL,
@@ -113,9 +116,12 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_alloc_ident = tf_ident_alloc,
 	.tf_dev_free_ident = tf_ident_free,
 	.tf_dev_alloc_tbl = tf_tbl_alloc,
+	.tf_dev_alloc_ext_tbl = tf_tbl_ext_alloc,
 	.tf_dev_free_tbl = tf_tbl_free,
+	.tf_dev_free_ext_tbl = tf_tbl_ext_free,
 	.tf_dev_alloc_search_tbl = NULL,
 	.tf_dev_set_tbl = tf_tbl_set,
+	.tf_dev_set_ext_tbl = tf_tbl_ext_set,
 	.tf_dev_get_tbl = tf_tbl_get,
 	.tf_dev_get_bulk_tbl = tf_tbl_bulk_get,
 	.tf_dev_alloc_tcam = tf_tcam_alloc,
drivers/net/bnxt/tf_core/tf_device_p4.h +0 -2
index 8fae18012..298e100f3 100644
@@ -47,8 +47,6 @@ struct tf_rm_element_cfg tf_tbl_p4[TF_TBL_TYPE_MAX] = {
 	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_DPORT },
 	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_S_IPV4 },
 	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_D_IPV4 },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_S_IPV6 },
-	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_D_IPV6 },
 	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_METER_PROF },
 	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_METER },
 	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_MIRROR },
drivers/net/bnxt/tf_core/tf_em.h +95 -0

99 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_em_common.c +116 -4

149 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_em_host.c +75 -5

109 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_em_system.c +6 -0
index 6dd115470..10768df03 100644
@@ -112,3 +112,9 @@ tf_em_ext_system_free(struct tf *tfp __rte_unused,
 {
 	return 0;
 }
+
+int tf_tbl_ext_system_set(struct tf *tfp __rte_unused,
+			  struct tf_tbl_set_parms *parms __rte_unused)
+{
+	return 0;
+}
drivers/net/bnxt/tf_core/tf_identifier.c +2 -2
index 211371081..219839272 100644
@@ -159,13 +159,13 @@ tf_ident_free(struct tf *tfp __rte_unused,
 	if (rc)
 		return rc;
 
-	if (!allocated) {
+	if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
 		TFP_DRV_LOG(ERR,
 			    "%s: Entry already free, type:%d, index:%d\n",
 			    tf_dir_2_str(parms->dir),
 			    parms->type,
 			    parms->id);
-		return rc;
+		return -EINVAL;
 	}
 
 	/* Free requested element */
drivers/net/bnxt/tf_core/tf_rm.h +5 -0
index f44fcca70..fd044801f 100644
@@ -12,6 +12,11 @@
 
 struct tf;
 
+/** RM return codes */
+#define TF_RM_ALLOCATED_ENTRY_FREE        0
+#define TF_RM_ALLOCATED_ENTRY_IN_USE      1
+#define TF_RM_ALLOCATED_NO_ENTRY_FOUND   -1
+
 /**
  * The Resource Manager (RM) module provides basic DB handling for
  * internal resources. These resources exists within the actual device
drivers/net/bnxt/tf_core/tf_tbl.c +5 -5
index 05e866dc6..3a3277329 100644
@@ -172,13 +172,13 @@ tf_tbl_free(struct tf *tfp __rte_unused,
 	if (rc)
 		return rc;
 
-	if (!allocated) {
+	if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
 		TFP_DRV_LOG(ERR,
 			    "%s: Entry already free, type:%d, index:%d\n",
 			    tf_dir_2_str(parms->dir),
 			    parms->type,
 			    parms->idx);
-		return rc;
+		return -EINVAL;
 	}
 
 	/* Free requested element */
@@ -233,7 +233,7 @@ tf_tbl_set(struct tf *tfp,
 	if (rc)
 		return rc;
 
-	if (!allocated) {
+	if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
 		TFP_DRV_LOG(ERR,
 		   "%s, Invalid or not allocated index, type:%d, idx:%d\n",
 		   tf_dir_2_str(parms->dir),
@@ -301,7 +301,7 @@ tf_tbl_get(struct tf *tfp,
 	if (rc)
 		return rc;
 
-	if (!allocated) {
+	if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
 		TFP_DRV_LOG(ERR,
 		   "%s, Invalid or not allocated index, type:%d, idx:%d\n",
 		   tf_dir_2_str(parms->dir),
@@ -374,7 +374,7 @@ tf_tbl_bulk_get(struct tf *tfp,
 		if (rc)
 			return rc;
 
-		if (!allocated) {
+		if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
 			TFP_DRV_LOG(ERR,
 				    "%s, Invalid or not allocated index, type:%d, idx:%d\n",
 				    tf_dir_2_str(parms->dir),
drivers/net/bnxt/tf_core/tf_tbl.h +12 -0
index eb560ffa7..2a10b47ce 100644
@@ -83,6 +83,10 @@ struct tf_tbl_alloc_parms {
 	 * [in] Type of the allocation
 	 */
 	enum tf_tbl_type type;
+	/**
+	 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
+	 */
+	uint32_t tbl_scope_id;
 	/**
 	 * [out] Idx of allocated entry or found entry (if search_enable)
 	 */
@@ -101,6 +105,10 @@ struct tf_tbl_free_parms {
 	 * [in] Type of the allocation type
 	 */
 	enum tf_tbl_type type;
+	/**
+	 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
+	 */
+	uint32_t tbl_scope_id;
 	/**
 	 * [in] Index to free
 	 */
@@ -168,6 +176,10 @@ struct tf_tbl_set_parms {
 	 * [in] Type of object to set
 	 */
 	enum tf_tbl_type type;
+	/**
+	 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
+	 */
+	uint32_t tbl_scope_id;
 	/**
 	 * [in] Entry data
 	 */
drivers/net/bnxt/tf_core/tf_tcam.c +4 -4
index b67159a54..b1092cd9d 100644
@@ -252,13 +252,13 @@ tf_tcam_free(struct tf *tfp,
 	if (rc)
 		return rc;
 
-	if (!allocated) {
+	if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
 		TFP_DRV_LOG(ERR,
 			    "%s: Entry already free, type:%d, index:%d\n",
 			    tf_dir_2_str(parms->dir),
 			    parms->type,
 			    parms->idx);
-		return rc;
+		return -EINVAL;
 	}
 
 	/* Free requested element */
@@ -362,13 +362,13 @@ tf_tcam_set(struct tf *tfp __rte_unused,
 	if (rc)
 		return rc;
 
-	if (!allocated) {
+	if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
 		TFP_DRV_LOG(ERR,
 			    "%s: Entry is not allocated, type:%d, index:%d\n",
 			    tf_dir_2_str(parms->dir),
 			    parms->type,
 			    parms->idx);
-		return rc;
+		return -EINVAL;
 	}
 
 	/* Convert TF type to HCAPI RM type */
drivers/net/bnxt/tf_core/tf_util.c +0 -4
index 5472a9aac..85f6e25f4 100644
@@ -92,10 +92,6 @@ tf_tbl_type_2_str(enum tf_tbl_type tbl_type)
 		return "NAT IPv4 Source";
 	case TF_TBL_TYPE_ACT_MODIFY_IPV4_DEST:
 		return "NAT IPv4 Destination";
-	case TF_TBL_TYPE_ACT_MODIFY_IPV6_SRC:
-		return "NAT IPv6 Source";
-	case TF_TBL_TYPE_ACT_MODIFY_IPV6_DEST:
-		return "NAT IPv6 Destination";
 	case TF_TBL_TYPE_METER_PROF:
 		return "Meter Profile";
 	case TF_TBL_TYPE_METER_INST:
Signature · 1 line
2.21.1 (Apple Git-122.3)
#184 lore raw

PATCH v4 27/51 net/bnxt: align CFA resources with RM

In reply to Ajit Khaparde

From: Randy Schacher <[email protected]>

- HCAPI resources need to align for Resource Manager
- Clean up unnecessary debug messages

---
 drivers/net/bnxt/tf_core/cfa_resource_types.h | 250 +++++++++---------
 drivers/net/bnxt/tf_core/tf_identifier.c      |   3 +-
 drivers/net/bnxt/tf_core/tf_msg.c             |  37 ++-
 drivers/net/bnxt/tf_core/tf_rm.c              |  21 +-
 drivers/net/bnxt/tf_core/tf_tbl.c             |   3 +-
 drivers/net/bnxt/tf_core/tf_tcam.c            |  28 +-
 6 files changed, 197 insertions(+), 145 deletions(-)
drivers/net/bnxt/tf_core/cfa_resource_types.h +132 -118
index 6e79facec..6d6651fde 100644
@@ -48,232 +48,246 @@
 #define CFA_RESOURCE_TYPE_P59_TBL_SCOPE       0xdUL
 /* L2 Func */
 #define CFA_RESOURCE_TYPE_P59_L2_FUNC         0xeUL
-/* EPOCH */
-#define CFA_RESOURCE_TYPE_P59_EPOCH           0xfUL
+/* EPOCH 0 */
+#define CFA_RESOURCE_TYPE_P59_EPOCH0          0xfUL
+/* EPOCH 1 */
+#define CFA_RESOURCE_TYPE_P59_EPOCH1          0x10UL
 /* Metadata */
-#define CFA_RESOURCE_TYPE_P59_METADATA        0x10UL
+#define CFA_RESOURCE_TYPE_P59_METADATA        0x11UL
 /* Connection Tracking Rule TCAM */
-#define CFA_RESOURCE_TYPE_P59_CT_RULE_TCAM    0x11UL
+#define CFA_RESOURCE_TYPE_P59_CT_RULE_TCAM    0x12UL
 /* Range Profile */
-#define CFA_RESOURCE_TYPE_P59_RANGE_PROF      0x12UL
+#define CFA_RESOURCE_TYPE_P59_RANGE_PROF      0x13UL
 /* Range */
-#define CFA_RESOURCE_TYPE_P59_RANGE           0x13UL
+#define CFA_RESOURCE_TYPE_P59_RANGE           0x14UL
 /* Link Aggrigation */
-#define CFA_RESOURCE_TYPE_P59_LAG             0x14UL
+#define CFA_RESOURCE_TYPE_P59_LAG             0x15UL
 /* VEB TCAM */
-#define CFA_RESOURCE_TYPE_P59_VEB_TCAM        0x15UL
+#define CFA_RESOURCE_TYPE_P59_VEB_TCAM        0x16UL
 #define CFA_RESOURCE_TYPE_P59_LAST           CFA_RESOURCE_TYPE_P59_VEB_TCAM
 
 
 /* Multicast Group */
-#define CFA_RESOURCE_TYPE_P58_MCG             0x0UL
+#define CFA_RESOURCE_TYPE_P58_MCG                 0x0UL
 /* Encap 8 byte record */
-#define CFA_RESOURCE_TYPE_P58_ENCAP_8B        0x1UL
+#define CFA_RESOURCE_TYPE_P58_ENCAP_8B            0x1UL
 /* Encap 16 byte record */
-#define CFA_RESOURCE_TYPE_P58_ENCAP_16B       0x2UL
+#define CFA_RESOURCE_TYPE_P58_ENCAP_16B           0x2UL
 /* Encap 64 byte record */
-#define CFA_RESOURCE_TYPE_P58_ENCAP_64B       0x3UL
+#define CFA_RESOURCE_TYPE_P58_ENCAP_64B           0x3UL
 /* Source Property MAC */
-#define CFA_RESOURCE_TYPE_P58_SP_MAC          0x4UL
+#define CFA_RESOURCE_TYPE_P58_SP_MAC              0x4UL
 /* Source Property MAC and IPv4 */
-#define CFA_RESOURCE_TYPE_P58_SP_MAC_IPV4     0x5UL
+#define CFA_RESOURCE_TYPE_P58_SP_MAC_IPV4         0x5UL
 /* Source Property MAC and IPv6 */
-#define CFA_RESOURCE_TYPE_P58_SP_MAC_IPV6     0x6UL
+#define CFA_RESOURCE_TYPE_P58_SP_MAC_IPV6         0x6UL
 /* Network Address Translation Source Port */
-#define CFA_RESOURCE_TYPE_P58_NAT_SPORT       0x7UL
+#define CFA_RESOURCE_TYPE_P58_NAT_SPORT           0x7UL
 /* Network Address Translation Destination Port */
-#define CFA_RESOURCE_TYPE_P58_NAT_DPORT       0x8UL
+#define CFA_RESOURCE_TYPE_P58_NAT_DPORT           0x8UL
 /* Network Address Translation Source IPv4 address */
-#define CFA_RESOURCE_TYPE_P58_NAT_S_IPV4      0x9UL
+#define CFA_RESOURCE_TYPE_P58_NAT_S_IPV4          0x9UL
 /* Network Address Translation Destination IPv4 address */
-#define CFA_RESOURCE_TYPE_P58_NAT_D_IPV4      0xaUL
-/* Network Address Translation Source IPv4 address */
-#define CFA_RESOURCE_TYPE_P58_NAT_S_IPV6      0xbUL
-/* Network Address Translation Destination IPv4 address */
-#define CFA_RESOURCE_TYPE_P58_NAT_D_IPV6      0xcUL
+#define CFA_RESOURCE_TYPE_P58_NAT_D_IPV4          0xaUL
 /* Meter */
-#define CFA_RESOURCE_TYPE_P58_METER           0xdUL
+#define CFA_RESOURCE_TYPE_P58_METER               0xbUL
 /* Flow State */
-#define CFA_RESOURCE_TYPE_P58_FLOW_STATE      0xeUL
+#define CFA_RESOURCE_TYPE_P58_FLOW_STATE          0xcUL
 /* Full Action Records */
-#define CFA_RESOURCE_TYPE_P58_FULL_ACTION     0xfUL
+#define CFA_RESOURCE_TYPE_P58_FULL_ACTION         0xdUL
 /* Action Record Format 0 */
-#define CFA_RESOURCE_TYPE_P58_FORMAT_0_ACTION 0x10UL
+#define CFA_RESOURCE_TYPE_P58_FORMAT_0_ACTION     0xeUL
+/* Action Record Ext Format 0 */
+#define CFA_RESOURCE_TYPE_P58_EXT_FORMAT_0_ACTION 0xfUL
+/* Action Record Format 1 */
+#define CFA_RESOURCE_TYPE_P58_FORMAT_1_ACTION     0x10UL
 /* Action Record Format 2 */
-#define CFA_RESOURCE_TYPE_P58_FORMAT_2_ACTION 0x11UL
+#define CFA_RESOURCE_TYPE_P58_FORMAT_2_ACTION     0x11UL
 /* Action Record Format 3 */
-#define CFA_RESOURCE_TYPE_P58_FORMAT_3_ACTION 0x12UL
+#define CFA_RESOURCE_TYPE_P58_FORMAT_3_ACTION     0x12UL
 /* Action Record Format 4 */
-#define CFA_RESOURCE_TYPE_P58_FORMAT_4_ACTION 0x13UL
+#define CFA_RESOURCE_TYPE_P58_FORMAT_4_ACTION     0x13UL
+/* Action Record Format 5 */
+#define CFA_RESOURCE_TYPE_P58_FORMAT_5_ACTION     0x14UL
+/* Action Record Format 6 */
+#define CFA_RESOURCE_TYPE_P58_FORMAT_6_ACTION     0x15UL
 /* L2 Context TCAM */
-#define CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM    0x14UL
+#define CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM        0x16UL
 /* L2 Context REMAP */
-#define CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP   0x15UL
+#define CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP       0x17UL
 /* Profile Func */
-#define CFA_RESOURCE_TYPE_P58_PROF_FUNC       0x16UL
+#define CFA_RESOURCE_TYPE_P58_PROF_FUNC           0x18UL
 /* Profile TCAM */
-#define CFA_RESOURCE_TYPE_P58_PROF_TCAM       0x17UL
+#define CFA_RESOURCE_TYPE_P58_PROF_TCAM           0x19UL
 /* Exact Match Profile Id */
-#define CFA_RESOURCE_TYPE_P58_EM_PROF_ID      0x18UL
+#define CFA_RESOURCE_TYPE_P58_EM_PROF_ID          0x1aUL
 /* Wildcard Profile Id */
-#define CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID 0x19UL
+#define CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID     0x1bUL
 /* Exact Match Record */
-#define CFA_RESOURCE_TYPE_P58_EM_REC          0x1aUL
+#define CFA_RESOURCE_TYPE_P58_EM_REC              0x1cUL
 /* Wildcard TCAM */
-#define CFA_RESOURCE_TYPE_P58_WC_TCAM         0x1bUL
+#define CFA_RESOURCE_TYPE_P58_WC_TCAM             0x1dUL
 /* Meter profile */
-#define CFA_RESOURCE_TYPE_P58_METER_PROF      0x1cUL
+#define CFA_RESOURCE_TYPE_P58_METER_PROF          0x1eUL
 /* Meter */
-#define CFA_RESOURCE_TYPE_P58_MIRROR          0x1dUL
+#define CFA_RESOURCE_TYPE_P58_MIRROR              0x1fUL
 /* Source Property TCAM */
-#define CFA_RESOURCE_TYPE_P58_SP_TCAM         0x1eUL
+#define CFA_RESOURCE_TYPE_P58_SP_TCAM             0x20UL
 /* Exact Match Flexible Key Builder */
-#define CFA_RESOURCE_TYPE_P58_EM_FKB          0x1fUL
+#define CFA_RESOURCE_TYPE_P58_EM_FKB              0x21UL
 /* Wildcard Flexible Key Builder */
-#define CFA_RESOURCE_TYPE_P58_WC_FKB          0x20UL
+#define CFA_RESOURCE_TYPE_P58_WC_FKB              0x22UL
 /* VEB TCAM */
-#define CFA_RESOURCE_TYPE_P58_VEB_TCAM        0x21UL
-#define CFA_RESOURCE_TYPE_P58_LAST           CFA_RESOURCE_TYPE_P58_VEB_TCAM
+#define CFA_RESOURCE_TYPE_P58_VEB_TCAM            0x23UL
+#define CFA_RESOURCE_TYPE_P58_LAST               CFA_RESOURCE_TYPE_P58_VEB_TCAM
 
 
 /* Multicast Group */
-#define CFA_RESOURCE_TYPE_P45_MCG             0x0UL
+#define CFA_RESOURCE_TYPE_P45_MCG                 0x0UL
 /* Encap 8 byte record */
-#define CFA_RESOURCE_TYPE_P45_ENCAP_8B        0x1UL
+#define CFA_RESOURCE_TYPE_P45_ENCAP_8B            0x1UL
 /* Encap 16 byte record */
-#define CFA_RESOURCE_TYPE_P45_ENCAP_16B       0x2UL
+#define CFA_RESOURCE_TYPE_P45_ENCAP_16B           0x2UL
 /* Encap 64 byte record */
-#define CFA_RESOURCE_TYPE_P45_ENCAP_64B       0x3UL
+#define CFA_RESOURCE_TYPE_P45_ENCAP_64B           0x3UL
 /* Source Property MAC */
-#define CFA_RESOURCE_TYPE_P45_SP_MAC          0x4UL
+#define CFA_RESOURCE_TYPE_P45_SP_MAC              0x4UL
 /* Source Property MAC and IPv4 */
-#define CFA_RESOURCE_TYPE_P45_SP_MAC_IPV4     0x5UL
+#define CFA_RESOURCE_TYPE_P45_SP_MAC_IPV4         0x5UL
 /* Source Property MAC and IPv6 */
-#define CFA_RESOURCE_TYPE_P45_SP_MAC_IPV6     0x6UL
+#define CFA_RESOURCE_TYPE_P45_SP_MAC_IPV6         0x6UL
 /* 64B Counters */
-#define CFA_RESOURCE_TYPE_P45_COUNTER_64B     0x7UL
+#define CFA_RESOURCE_TYPE_P45_COUNTER_64B         0x7UL
 /* Network Address Translation Source Port */
-#define CFA_RESOURCE_TYPE_P45_NAT_SPORT       0x8UL
+#define CFA_RESOURCE_TYPE_P45_NAT_SPORT           0x8UL
 /* Network Address Translation Destination Port */
-#define CFA_RESOURCE_TYPE_P45_NAT_DPORT       0x9UL
+#define CFA_RESOURCE_TYPE_P45_NAT_DPORT           0x9UL
 /* Network Address Translation Source IPv4 address */
-#define CFA_RESOURCE_TYPE_P45_NAT_S_IPV4      0xaUL
+#define CFA_RESOURCE_TYPE_P45_NAT_S_IPV4          0xaUL
 /* Network Address Translation Destination IPv4 address */
-#define CFA_RESOURCE_TYPE_P45_NAT_D_IPV4      0xbUL
-/* Network Address Translation Source IPv6 address */
-#define CFA_RESOURCE_TYPE_P45_NAT_S_IPV6      0xcUL
-/* Network Address Translation Destination IPv6 address */
-#define CFA_RESOURCE_TYPE_P45_NAT_D_IPV6      0xdUL
+#define CFA_RESOURCE_TYPE_P45_NAT_D_IPV4          0xbUL
 /* Meter */
-#define CFA_RESOURCE_TYPE_P45_METER           0xeUL
+#define CFA_RESOURCE_TYPE_P45_METER               0xcUL
 /* Flow State */
-#define CFA_RESOURCE_TYPE_P45_FLOW_STATE      0xfUL
+#define CFA_RESOURCE_TYPE_P45_FLOW_STATE          0xdUL
 /* Full Action Records */
-#define CFA_RESOURCE_TYPE_P45_FULL_ACTION     0x10UL
+#define CFA_RESOURCE_TYPE_P45_FULL_ACTION         0xeUL
 /* Action Record Format 0 */
-#define CFA_RESOURCE_TYPE_P45_FORMAT_0_ACTION 0x11UL
+#define CFA_RESOURCE_TYPE_P45_FORMAT_0_ACTION     0xfUL
+/* Action Record Ext Format 0 */
+#define CFA_RESOURCE_TYPE_P45_EXT_FORMAT_0_ACTION 0x10UL
+/* Action Record Format 1 */
+#define CFA_RESOURCE_TYPE_P45_FORMAT_1_ACTION     0x11UL
 /* Action Record Format 2 */
-#define CFA_RESOURCE_TYPE_P45_FORMAT_2_ACTION 0x12UL
+#define CFA_RESOURCE_TYPE_P45_FORMAT_2_ACTION     0x12UL
 /* Action Record Format 3 */
-#define CFA_RESOURCE_TYPE_P45_FORMAT_3_ACTION 0x13UL
+#define CFA_RESOURCE_TYPE_P45_FORMAT_3_ACTION     0x13UL
 /* Action Record Format 4 */
-#define CFA_RESOURCE_TYPE_P45_FORMAT_4_ACTION 0x14UL
+#define CFA_RESOURCE_TYPE_P45_FORMAT_4_ACTION     0x14UL
+/* Action Record Format 5 */
+#define CFA_RESOURCE_TYPE_P45_FORMAT_5_ACTION     0x15UL
+/* Action Record Format 6 */
+#define CFA_RESOURCE_TYPE_P45_FORMAT_6_ACTION     0x16UL
 /* L2 Context TCAM */
-#define CFA_RESOURCE_TYPE_P45_L2_CTXT_TCAM    0x15UL
+#define CFA_RESOURCE_TYPE_P45_L2_CTXT_TCAM        0x17UL
 /* L2 Context REMAP */
-#define CFA_RESOURCE_TYPE_P45_L2_CTXT_REMAP   0x16UL
+#define CFA_RESOURCE_TYPE_P45_L2_CTXT_REMAP       0x18UL
 /* Profile Func */
-#define CFA_RESOURCE_TYPE_P45_PROF_FUNC       0x17UL
+#define CFA_RESOURCE_TYPE_P45_PROF_FUNC           0x19UL
 /* Profile TCAM */
-#define CFA_RESOURCE_TYPE_P45_PROF_TCAM       0x18UL
+#define CFA_RESOURCE_TYPE_P45_PROF_TCAM           0x1aUL
 /* Exact Match Profile Id */
-#define CFA_RESOURCE_TYPE_P45_EM_PROF_ID      0x19UL
+#define CFA_RESOURCE_TYPE_P45_EM_PROF_ID          0x1bUL
 /* Exact Match Record */
-#define CFA_RESOURCE_TYPE_P45_EM_REC          0x1aUL
+#define CFA_RESOURCE_TYPE_P45_EM_REC              0x1cUL
 /* Wildcard Profile Id */
-#define CFA_RESOURCE_TYPE_P45_WC_TCAM_PROF_ID 0x1bUL
+#define CFA_RESOURCE_TYPE_P45_WC_TCAM_PROF_ID     0x1dUL
 /* Wildcard TCAM */
-#define CFA_RESOURCE_TYPE_P45_WC_TCAM         0x1cUL
+#define CFA_RESOURCE_TYPE_P45_WC_TCAM             0x1eUL
 /* Meter profile */
-#define CFA_RESOURCE_TYPE_P45_METER_PROF      0x1dUL
+#define CFA_RESOURCE_TYPE_P45_METER_PROF          0x1fUL
 /* Meter */
-#define CFA_RESOURCE_TYPE_P45_MIRROR          0x1eUL
+#define CFA_RESOURCE_TYPE_P45_MIRROR              0x20UL
 /* Source Property TCAM */
-#define CFA_RESOURCE_TYPE_P45_SP_TCAM         0x1fUL
+#define CFA_RESOURCE_TYPE_P45_SP_TCAM             0x21UL
 /* VEB TCAM */
-#define CFA_RESOURCE_TYPE_P45_VEB_TCAM        0x20UL
+#define CFA_RESOURCE_TYPE_P45_VEB_TCAM            0x22UL
 /* Table Scope */
-#define CFA_RESOURCE_TYPE_P45_TBL_SCOPE       0x21UL
-#define CFA_RESOURCE_TYPE_P45_LAST           CFA_RESOURCE_TYPE_P45_TBL_SCOPE
+#define CFA_RESOURCE_TYPE_P45_TBL_SCOPE           0x23UL
+#define CFA_RESOURCE_TYPE_P45_LAST               CFA_RESOURCE_TYPE_P45_TBL_SCOPE
 
 
 /* Multicast Group */
-#define CFA_RESOURCE_TYPE_P4_MCG             0x0UL
+#define CFA_RESOURCE_TYPE_P4_MCG                 0x0UL
 /* Encap 8 byte record */
-#define CFA_RESOURCE_TYPE_P4_ENCAP_8B        0x1UL
+#define CFA_RESOURCE_TYPE_P4_ENCAP_8B            0x1UL
 /* Encap 16 byte record */
-#define CFA_RESOURCE_TYPE_P4_ENCAP_16B       0x2UL
+#define CFA_RESOURCE_TYPE_P4_ENCAP_16B           0x2UL
 /* Encap 64 byte record */
-#define CFA_RESOURCE_TYPE_P4_ENCAP_64B       0x3UL
+#define CFA_RESOURCE_TYPE_P4_ENCAP_64B           0x3UL
 /* Source Property MAC */
-#define CFA_RESOURCE_TYPE_P4_SP_MAC          0x4UL
+#define CFA_RESOURCE_TYPE_P4_SP_MAC              0x4UL
 /* Source Property MAC and IPv4 */
-#define CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4     0x5UL
+#define CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4         0x5UL
 /* Source Property MAC and IPv6 */
-#define CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6     0x6UL
+#define CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6         0x6UL
 /* 64B Counters */
-#define CFA_RESOURCE_TYPE_P4_COUNTER_64B     0x7UL
+#define CFA_RESOURCE_TYPE_P4_COUNTER_64B         0x7UL
 /* Network Address Translation Source Port */
-#define CFA_RESOURCE_TYPE_P4_NAT_SPORT       0x8UL
+#define CFA_RESOURCE_TYPE_P4_NAT_SPORT           0x8UL
 /* Network Address Translation Destination Port */
-#define CFA_RESOURCE_TYPE_P4_NAT_DPORT       0x9UL
+#define CFA_RESOURCE_TYPE_P4_NAT_DPORT           0x9UL
 /* Network Address Translation Source IPv4 address */
-#define CFA_RESOURCE_TYPE_P4_NAT_S_IPV4      0xaUL
+#define CFA_RESOURCE_TYPE_P4_NAT_S_IPV4          0xaUL
 /* Network Address Translation Destination IPv4 address */
-#define CFA_RESOURCE_TYPE_P4_NAT_D_IPV4      0xbUL
-/* Network Address Translation Source IPv6 address */
-#define CFA_RESOURCE_TYPE_P4_NAT_S_IPV6      0xcUL
-/* Network Address Translation Destination IPv6 address */
-#define CFA_RESOURCE_TYPE_P4_NAT_D_IPV6      0xdUL
+#define CFA_RESOURCE_TYPE_P4_NAT_D_IPV4          0xbUL
 /* Meter */
-#define CFA_RESOURCE_TYPE_P4_METER           0xeUL
+#define CFA_RESOURCE_TYPE_P4_METER               0xcUL
 /* Flow State */
-#define CFA_RESOURCE_TYPE_P4_FLOW_STATE      0xfUL
+#define CFA_RESOURCE_TYPE_P4_FLOW_STATE          0xdUL
 /* Full Action Records */
-#define CFA_RESOURCE_TYPE_P4_FULL_ACTION     0x10UL
+#define CFA_RESOURCE_TYPE_P4_FULL_ACTION         0xeUL
 /* Action Record Format 0 */
-#define CFA_RESOURCE_TYPE_P4_FORMAT_0_ACTION 0x11UL
+#define CFA_RESOURCE_TYPE_P4_FORMAT_0_ACTION     0xfUL
+/* Action Record Ext Format 0 */
+#define CFA_RESOURCE_TYPE_P4_EXT_FORMAT_0_ACTION 0x10UL
+/* Action Record Format 1 */
+#define CFA_RESOURCE_TYPE_P4_FORMAT_1_ACTION     0x11UL
 /* Action Record Format 2 */
-#define CFA_RESOURCE_TYPE_P4_FORMAT_2_ACTION 0x12UL
+#define CFA_RESOURCE_TYPE_P4_FORMAT_2_ACTION     0x12UL
 /* Action Record Format 3 */
-#define CFA_RESOURCE_TYPE_P4_FORMAT_3_ACTION 0x13UL
+#define CFA_RESOURCE_TYPE_P4_FORMAT_3_ACTION     0x13UL
 /* Action Record Format 4 */
-#define CFA_RESOURCE_TYPE_P4_FORMAT_4_ACTION 0x14UL
+#define CFA_RESOURCE_TYPE_P4_FORMAT_4_ACTION     0x14UL
+/* Action Record Format 5 */
+#define CFA_RESOURCE_TYPE_P4_FORMAT_5_ACTION     0x15UL
+/* Action Record Format 6 */
+#define CFA_RESOURCE_TYPE_P4_FORMAT_6_ACTION     0x16UL
 /* L2 Context TCAM */
-#define CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM    0x15UL
+#define CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM        0x17UL
 /* L2 Context REMAP */
-#define CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP   0x16UL
+#define CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP       0x18UL
 /* Profile Func */
-#define CFA_RESOURCE_TYPE_P4_PROF_FUNC       0x17UL
+#define CFA_RESOURCE_TYPE_P4_PROF_FUNC           0x19UL
 /* Profile TCAM */
-#define CFA_RESOURCE_TYPE_P4_PROF_TCAM       0x18UL
+#define CFA_RESOURCE_TYPE_P4_PROF_TCAM           0x1aUL
 /* Exact Match Profile Id */
-#define CFA_RESOURCE_TYPE_P4_EM_PROF_ID      0x19UL
+#define CFA_RESOURCE_TYPE_P4_EM_PROF_ID          0x1bUL
 /* Exact Match Record */
-#define CFA_RESOURCE_TYPE_P4_EM_REC          0x1aUL
+#define CFA_RESOURCE_TYPE_P4_EM_REC              0x1cUL
 /* Wildcard Profile Id */
-#define CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID 0x1bUL
+#define CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID     0x1dUL
 /* Wildcard TCAM */
-#define CFA_RESOURCE_TYPE_P4_WC_TCAM         0x1cUL
+#define CFA_RESOURCE_TYPE_P4_WC_TCAM             0x1eUL
 /* Meter profile */
-#define CFA_RESOURCE_TYPE_P4_METER_PROF      0x1dUL
+#define CFA_RESOURCE_TYPE_P4_METER_PROF          0x1fUL
 /* Meter */
-#define CFA_RESOURCE_TYPE_P4_MIRROR          0x1eUL
+#define CFA_RESOURCE_TYPE_P4_MIRROR              0x20UL
 /* Source Property TCAM */
-#define CFA_RESOURCE_TYPE_P4_SP_TCAM         0x1fUL
+#define CFA_RESOURCE_TYPE_P4_SP_TCAM             0x21UL
 /* Table Scope */
-#define CFA_RESOURCE_TYPE_P4_TBL_SCOPE       0x20UL
-#define CFA_RESOURCE_TYPE_P4_LAST           CFA_RESOURCE_TYPE_P4_TBL_SCOPE
+#define CFA_RESOURCE_TYPE_P4_TBL_SCOPE           0x22UL
+#define CFA_RESOURCE_TYPE_P4_LAST               CFA_RESOURCE_TYPE_P4_TBL_SCOPE
 
 
 #endif /* _CFA_RESOURCE_TYPES_H_ */
drivers/net/bnxt/tf_core/tf_identifier.c +2 -1
index 219839272..2cc43b40f 100644
@@ -59,7 +59,8 @@ tf_ident_bind(struct tf *tfp,
 
 	init = 1;
 
-	printf("Identifier - initialized\n");
+	TFP_DRV_LOG(INFO,
+		    "Identifier - initialized\n");
 
 	return 0;
 }
drivers/net/bnxt/tf_core/tf_msg.c +26 -11
index 7fffb6baf..659065de3 100644
@@ -18,6 +18,9 @@
 #include "hwrm_tf.h"
 #include "tf_em.h"
 
+/* Logging defines */
+#define TF_RM_MSG_DEBUG  0
+
 /**
  * This is the MAX data we can transport across regular HWRM
  */
@@ -215,7 +218,7 @@ tf_msg_session_resc_qcaps(struct tf *tfp,
 
 	rc = tfp_send_msg_direct(tfp, &parms);
 	if (rc)
-		return rc;
+		goto cleanup;
 
 	/* Process the response
 	 * Should always get expected number of entries
@@ -225,31 +228,39 @@ tf_msg_session_resc_qcaps(struct tf *tfp,
 			    "%s: QCAPS message size error, rc:%s\n",
 			    tf_dir_2_str(dir),
 			    strerror(-EINVAL));
-		return -EINVAL;
+		rc = -EINVAL;
+		goto cleanup;
 	}
 
+#if (TF_RM_MSG_DEBUG == 1)
 	printf("size: %d\n", tfp_le_to_cpu_32(resp.size));
+#endif /* (TF_RM_MSG_DEBUG == 1) */
 
 	/* Post process the response */
 	data = (struct tf_rm_resc_req_entry *)qcaps_buf.va_addr;
 
+#if (TF_RM_MSG_DEBUG == 1)
 	printf("\nQCAPS\n");
+#endif /* (TF_RM_MSG_DEBUG == 1) */
 	for (i = 0; i < size; i++) {
 		query[i].type = tfp_le_to_cpu_32(data[i].type);
 		query[i].min = tfp_le_to_cpu_16(data[i].min);
 		query[i].max = tfp_le_to_cpu_16(data[i].max);
 
+#if (TF_RM_MSG_DEBUG == 1)
 		printf("type: %d(0x%x) %d %d\n",
 		       query[i].type,
 		       query[i].type,
 		       query[i].min,
 		       query[i].max);
+#endif /* (TF_RM_MSG_DEBUG == 1) */
 
 	}
 
 	*resv_strategy = resp.flags &
 	      HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_MASK;
 
+cleanup:
 	tf_msg_free_dma_buf(&qcaps_buf);
 
 	return rc;
@@ -293,8 +304,10 @@ tf_msg_session_resc_alloc(struct tf *tfp,
 
 	dma_size = size * sizeof(struct tf_rm_resc_entry);
 	rc = tf_msg_alloc_dma_buf(&resv_buf, dma_size);
-	if (rc)
+	if (rc) {
+		tf_msg_free_dma_buf(&req_buf);
 		return rc;
+	}
 
 	/* Populate the request */
 	req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
@@ -320,7 +333,7 @@ tf_msg_session_resc_alloc(struct tf *tfp,
 
 	rc = tfp_send_msg_direct(tfp, &parms);
 	if (rc)
-		return rc;
+		goto cleanup;
 
 	/* Process the response
 	 * Should always get expected number of entries
@@ -330,11 +343,14 @@ tf_msg_session_resc_alloc(struct tf *tfp,
 			    "%s: Alloc message size error, rc:%s\n",
 			    tf_dir_2_str(dir),
 			    strerror(-EINVAL));
-		return -EINVAL;
+		rc = -EINVAL;
+		goto cleanup;
 	}
 
+#if (TF_RM_MSG_DEBUG == 1)
 	printf("\nRESV\n");
 	printf("size: %d\n", tfp_le_to_cpu_32(resp.size));
+#endif /* (TF_RM_MSG_DEBUG == 1) */
 
 	/* Post process the response */
 	resv_data = (struct tf_rm_resc_entry *)resv_buf.va_addr;
@@ -343,14 +359,17 @@ tf_msg_session_resc_alloc(struct tf *tfp,
 		resv[i].start = tfp_le_to_cpu_16(resv_data[i].start);
 		resv[i].stride = tfp_le_to_cpu_16(resv_data[i].stride);
 
+#if (TF_RM_MSG_DEBUG == 1)
 		printf("%d type: %d(0x%x) %d %d\n",
 		       i,
 		       resv[i].type,
 		       resv[i].type,
 		       resv[i].start,
 		       resv[i].stride);
+#endif /* (TF_RM_MSG_DEBUG == 1) */
 	}
 
+cleanup:
 	tf_msg_free_dma_buf(&req_buf);
 	tf_msg_free_dma_buf(&resv_buf);
 
@@ -412,8 +431,6 @@ tf_msg_session_resc_flush(struct tf *tfp,
 	parms.mailbox = TF_KONG_MB;
 
 	rc = tfp_send_msg_direct(tfp, &parms);
-	if (rc)
-		return rc;
 
 	tf_msg_free_dma_buf(&resv_buf);
 
@@ -434,7 +451,7 @@ tf_msg_insert_em_internal_entry(struct tf *tfp,
 	struct tf_session *tfs = (struct tf_session *)(tfp->session->core_data);
 	struct tf_em_64b_entry *em_result =
 		(struct tf_em_64b_entry *)em_parms->em_record;
-	uint32_t flags;
+	uint16_t flags;
 
 	req.fw_session_id =
 		tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
@@ -480,7 +497,7 @@ tf_msg_delete_em_entry(struct tf *tfp,
 	struct tfp_send_msg_parms parms = { 0 };
 	struct hwrm_tf_em_delete_input req = { 0 };
 	struct hwrm_tf_em_delete_output resp = { 0 };
-	uint32_t flags;
+	uint16_t flags;
 	struct tf_session *tfs =
 		(struct tf_session *)(tfp->session->core_data);
 
@@ -726,8 +743,6 @@ tf_msg_tcam_entry_set(struct tf *tfp,
 
 	rc = tfp_send_msg_direct(tfp,
 				 &mparms);
-	if (rc)
-		goto cleanup;
 
 cleanup:
 	tf_msg_free_dma_buf(&buf);
drivers/net/bnxt/tf_core/tf_rm.c +8 -13
index e7af9eb84..30313e2ea 100644
@@ -17,6 +17,9 @@
 #include "tfp.h"
 #include "tf_msg.h"
 
+/* Logging defines */
+#define TF_RM_DEBUG  0
+
 /**
  * Generic RM Element data type that an RM DB is build upon.
  */
@@ -120,16 +123,11 @@ tf_rm_count_hcapi_reservations(enum tf_dir dir,
 		    cfg[i].cfg_type == TF_RM_ELEM_CFG_NULL &&
 		    reservations[i] > 0) {
 			TFP_DRV_LOG(ERR,
-				"%s, %s, %s allocation not supported\n",
-				tf_device_module_type_2_str(type),
-				tf_dir_2_str(dir),
-				tf_device_module_type_subtype_2_str(type, i));
-			printf("%s, %s, %s allocation of %d not supported\n",
+				"%s, %s, %s allocation of %d not supported\n",
 				tf_device_module_type_2_str(type),
 				tf_dir_2_str(dir),
-			       tf_device_module_type_subtype_2_str(type, i),
-			       reservations[i]);
-
+				tf_device_module_type_subtype_2_str(type, i),
+				reservations[i]);
 		}
 	}
 
@@ -549,11 +547,6 @@ tf_rm_create_db(struct tf *tfp,
 			db[i].alloc.entry.start = resv[j].start;
 			db[i].alloc.entry.stride = resv[j].stride;
 
-			printf("Entry:%d Start:%d Stride:%d\n",
-			       i,
-			       resv[j].start,
-			       resv[j].stride);
-
 			/* Only allocate BA pool if so requested */
 			if (parms->cfg[i].cfg_type == TF_RM_ELEM_CFG_HCAPI_BA) {
 				/* Create pool */
@@ -603,10 +596,12 @@ tf_rm_create_db(struct tf *tfp,
 	rm_db->type = parms->type;
 	*parms->rm_db = (void *)rm_db;
 
+#if (TF_RM_DEBUG == 1)
 	printf("%s: type:%d num_entries:%d\n",
 	       tf_dir_2_str(parms->dir),
 	       parms->type,
 	       i);
+#endif /* (TF_RM_DEBUG == 1) */
 
 	tfp_free((void *)req);
 	tfp_free((void *)resv);
drivers/net/bnxt/tf_core/tf_tbl.c +2 -1
index 3a3277329..7d4daaf2d 100644
@@ -74,7 +74,8 @@ tf_tbl_bind(struct tf *tfp,
 
 	init = 1;
 
-	printf("Table Type - initialized\n");
+	TFP_DRV_LOG(INFO,
+		    "Table Type - initialized\n");
 
 	return 0;
 }
drivers/net/bnxt/tf_core/tf_tcam.c +27 -1
index b1092cd9d..1c48b5363 100644
@@ -81,7 +81,8 @@ tf_tcam_bind(struct tf *tfp,
 
 	init = 1;
 
-	printf("TCAM - initialized\n");
+	TFP_DRV_LOG(INFO,
+		    "TCAM - initialized\n");
 
 	return 0;
 }
@@ -275,6 +276,31 @@ tf_tcam_free(struct tf *tfp,
 		return rc;
 	}
 
+	if (parms->type == TF_TCAM_TBL_TYPE_WC_TCAM) {
+		int i;
+
+		for (i = -1; i < 3; i += 3) {
+			aparms.index += i;
+			rc = tf_rm_is_allocated(&aparms);
+			if (rc)
+				return rc;
+
+			if (allocated == TF_RM_ALLOCATED_ENTRY_IN_USE) {
+				/* Free requested element */
+				fparms.index = aparms.index;
+				rc = tf_rm_free(&fparms);
+				if (rc) {
+					TFP_DRV_LOG(ERR,
+						    "%s: Free failed, type:%d, index:%d\n",
+						    tf_dir_2_str(parms->dir),
+						    parms->type,
+						    fparms.index);
+					return rc;
+				}
+			}
+		}
+	}
+
 	/* Convert TF type to HCAPI RM type */
 	hparms.rm_db = tcam_db[parms->dir];
 	hparms.db_index = parms->type;
Signature · 1 line
2.21.1 (Apple Git-122.3)
#185 lore raw

PATCH v4 28/51 net/bnxt: implement IF tables set and get

In reply to Ajit Khaparde

From: Jay Ding <[email protected]>

- Implement set/get for PROF_SPIF_CTXT, LKUP_PF_DFLT_ARP, PROF_PF_ERR_ARP with tunneled HWRM messages
- Add IF table for PROF_PARIF_DFLT_ARP
- Fix page size offset in the HCAPI code
- Fix Entry offset calculation

---
 drivers/net/bnxt/hcapi/cfa_p40_tbl.h     |  53 +++++
 drivers/net/bnxt/hcapi/hcapi_cfa_defs.h  |  12 +-
 drivers/net/bnxt/hcapi/hcapi_cfa_p4.c    |   8 +-
 drivers/net/bnxt/hcapi/hcapi_cfa_p4.h    |  18 +-
 drivers/net/bnxt/meson.build             |   2 +-
 drivers/net/bnxt/tf_core/Makefile        |   2 +
 drivers/net/bnxt/tf_core/hwrm_tf.h       |  63 +++++-
 drivers/net/bnxt/tf_core/tf_core.c       | 116 +++++++++++
 drivers/net/bnxt/tf_core/tf_core.h       | 104 ++++++++++
 drivers/net/bnxt/tf_core/tf_device.c     |  21 ++
 drivers/net/bnxt/tf_core/tf_device.h     |  39 ++++
 drivers/net/bnxt/tf_core/tf_device_p4.c  |   5 +
 drivers/net/bnxt/tf_core/tf_device_p4.h  |  10 +
 drivers/net/bnxt/tf_core/tf_em_common.c  |   5 +-
 drivers/net/bnxt/tf_core/tf_em_host.c    |  12 +-
 drivers/net/bnxt/tf_core/tf_identifier.c |   3 +-
 drivers/net/bnxt/tf_core/tf_if_tbl.c     | 178 +++++++++++++++++
 drivers/net/bnxt/tf_core/tf_if_tbl.h     | 236 +++++++++++++++++++++++
 drivers/net/bnxt/tf_core/tf_msg.c        | 186 +++++++++++++++---
 drivers/net/bnxt/tf_core/tf_msg.h        |  30 +++
 drivers/net/bnxt/tf_core/tf_session.c    |  14 +-
 21 files changed, 1060 insertions(+), 57 deletions(-)
 create mode 100644 drivers/net/bnxt/tf_core/tf_if_tbl.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_if_tbl.h
drivers/net/bnxt/hcapi/cfa_p40_tbl.h +53 -0
index c30e4f49c..3243b3f2b 100644
@@ -127,6 +127,11 @@ const struct hcapi_cfa_field cfa_p40_prof_profile_tcam_remap_mem_layout[] = {
 	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_PROFILE_ID_NUM_BITS},
 	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_KEY_ID_BITPOS,
 	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_TCAM_KEY_ID_NUM_BITS},
+	/* Fields below not generated through automation */
+	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_BYPASS_OPT_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_BYPASS_OPT_NUM_BITS},
+	{CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_ACT_REC_PTR_BITPOS,
+	 CFA_P40_PROF_PROFILE_TCAM_REMAP_MEM_ACT_REC_PTR_NUM_BITS},
 };
 
 const struct hcapi_cfa_field cfa_p40_prof_profile_tcam_layout[] = {
@@ -247,4 +252,52 @@ const struct hcapi_cfa_field cfa_p40_eem_key_tbl_layout[] = {
 	 CFA_P40_EEM_KEY_TBL_AR_PTR_NUM_BITS},
 
 };
+
+const struct hcapi_cfa_field cfa_p40_mirror_tbl_layout[] = {
+	{CFA_P40_MIRROR_TBL_SP_PTR_BITPOS,
+	 CFA_P40_MIRROR_TBL_SP_PTR_NUM_BITS},
+
+	{CFA_P40_MIRROR_TBL_IGN_DROP_BITPOS,
+	 CFA_P40_MIRROR_TBL_IGN_DROP_NUM_BITS},
+
+	{CFA_P40_MIRROR_TBL_COPY_BITPOS,
+	 CFA_P40_MIRROR_TBL_COPY_NUM_BITS},
+
+	{CFA_P40_MIRROR_TBL_EN_BITPOS,
+	 CFA_P40_MIRROR_TBL_EN_NUM_BITS},
+
+	{CFA_P40_MIRROR_TBL_AR_PTR_BITPOS,
+	 CFA_P40_MIRROR_TBL_AR_PTR_NUM_BITS},
+};
+
+/* P45 Defines */
+
+const struct hcapi_cfa_field cfa_p45_prof_l2_ctxt_tcam_layout[] = {
+	{CFA_P45_PROF_L2_CTXT_TCAM_VALID_BITPOS,
+	 CFA_P45_PROF_L2_CTXT_TCAM_VALID_NUM_BITS},
+	{CFA_P45_PROF_L2_CTXT_TCAM_SPARIF_BITPOS,
+	 CFA_P45_PROF_L2_CTXT_TCAM_SPARIF_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_KEY_TYPE_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_KEY_TYPE_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_TUN_HDR_TYPE_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_TUN_HDR_TYPE_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_T_L2_NUMTAGS_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_T_L2_NUMTAGS_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_L2_NUMTAGS_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_L2_NUMTAGS_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_MAC1_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_MAC1_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_T_OVID_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_T_OVID_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_T_IVID_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_T_IVID_NUM_BITS},
+	{CFA_P45_PROF_L2_CTXT_TCAM_SVIF_BITPOS,
+	 CFA_P45_PROF_L2_CTXT_TCAM_SVIF_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_MAC0_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_MAC0_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_OVID_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_OVID_NUM_BITS},
+	{CFA_P40_PROF_L2_CTXT_TCAM_IVID_BITPOS,
+	 CFA_P40_PROF_L2_CTXT_TCAM_IVID_NUM_BITS},
+};
 #endif /* _CFA_P40_TBL_H_ */
drivers/net/bnxt/hcapi/hcapi_cfa_defs.h +6 -6
index ea8d99d01..53a284887 100644
@@ -35,10 +35,6 @@
 
 #define CFA_GLOBAL_CFG_DATA_SZ (100)
 
-#if SUPPORT_CFA_HW_P4 && SUPPORT_CFA_HW_P58 && SUPPORT_CFA_HW_P59
-#define SUPPORT_CFA_HW_ALL (1)
-#endif
-
 #include "hcapi_cfa_p4.h"
 #define CFA_PROF_L2CTXT_TCAM_MAX_FIELD_CNT CFA_P40_PROF_L2_CTXT_TCAM_MAX_FLD
 #define CFA_PROF_L2CTXT_REMAP_MAX_FIELD_CNT CFA_P40_PROF_L2_CTXT_RMP_DR_MAX_FLD
@@ -121,6 +117,8 @@ struct hcapi_cfa_layout {
 	const struct hcapi_cfa_field *field_array;
 	/** [out] number of HW field entries in the HW layout field array */
 	uint32_t array_sz;
+	/** [out] layout_id - layout id associated with the layout */
+	uint16_t layout_id;
 };
 
 /**
@@ -247,6 +245,8 @@ struct hcapi_cfa_key_tbl {
 	 *  applicable for newer chip
 	 */
 	uint8_t *base1;
+	/** [in] Page size for EEM tables */
+	uint32_t page_size;
 };
 
 /**
@@ -267,7 +267,7 @@ struct hcapi_cfa_key_obj {
 struct hcapi_cfa_key_data {
 	/** [in] For on-chip key table, it is the offset in unit of smallest
 	 *  key. For off-chip key table, it is the byte offset relative
-	 *  to the key record memory base.
+	 *  to the key record memory base and adjusted for page and entry size.
 	 */
 	uint32_t offset;
 	/** [in] HW key data buffer pointer */
@@ -668,5 +668,5 @@ int hcapi_cfa_key_hw_op(struct hcapi_cfa_hwop *op,
 			struct hcapi_cfa_key_loc *key_loc);
 
 uint64_t hcapi_get_table_page(struct hcapi_cfa_em_table *mem,
-			      uint32_t offset);
+			      uint32_t page);
 #endif /* HCAPI_CFA_DEFS_H_ */
drivers/net/bnxt/hcapi/hcapi_cfa_p4.c +4 -4
index 42b37da0f..a01bbdbbb 100644
@@ -13,7 +13,6 @@
 #include "hcapi_cfa_defs.h"
 
 #define HCAPI_CFA_LKUP_SEED_MEM_SIZE 512
-#define TF_EM_PAGE_SIZE (1 << 21)
 uint32_t hcapi_cfa_lkup_lkup3_init_cfg;
 uint32_t hcapi_cfa_lkup_em_seed_mem[HCAPI_CFA_LKUP_SEED_MEM_SIZE];
 bool hcapi_cfa_lkup_init;
@@ -199,10 +198,9 @@ static uint32_t hcapi_cfa_lookup3_hash(uint8_t *in_key)
 
 
 uint64_t hcapi_get_table_page(struct hcapi_cfa_em_table *mem,
-			      uint32_t offset)
+			      uint32_t page)
 {
 	int level = 0;
-	int page = offset / TF_EM_PAGE_SIZE;
 	uint64_t addr;
 
 	if (mem == NULL)
@@ -362,7 +360,9 @@ int hcapi_cfa_key_hw_op(struct hcapi_cfa_hwop *op,
 	op->hw.base_addr =
 		hcapi_get_table_page((struct hcapi_cfa_em_table *)
 				     key_tbl->base0,
-				     key_obj->offset);
+				     key_obj->offset / key_tbl->page_size);
+	/* Offset is adjusted to be the offset into the page */
+	key_obj->offset = key_obj->offset % key_tbl->page_size;
 
 	if (op->hw.base_addr == 0)
 		return -1;
drivers/net/bnxt/hcapi/hcapi_cfa_p4.h +17 -1
index 0661d6363..c6113707f 100644
@@ -21,6 +21,10 @@ enum cfa_p4_tbl_id {
 	CFA_P4_TBL_WC_TCAM_REMAP,
 	CFA_P4_TBL_VEB_TCAM,
 	CFA_P4_TBL_SP_TCAM,
+	CFA_P4_TBL_PROF_SPIF_DFLT_L2CTXT,
+	CFA_P4_TBL_PROF_PARIF_DFLT_ACT_REC_PTR,
+	CFA_P4_TBL_PROF_PARIF_ERR_ACT_REC_PTR,
+	CFA_P4_TBL_LKUP_PARIF_DFLT_ACT_REC_PTR,
 	CFA_P4_TBL_MAX
 };
 
@@ -333,17 +337,29 @@ enum cfa_p4_action_sram_entry_type {
 	 */
 
 	/** SRAM Action Record */
-	CFA_P4_ACTION_SRAM_ENTRY_TYPE_ACT,
+	CFA_P4_ACTION_SRAM_ENTRY_TYPE_FULL_ACTION,
+
+	CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_0_ACTION,
+	CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_1_ACTION,
+	CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_2_ACTION,
+	CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_3_ACTION,
+	CFA_P4_ACTION_SRAM_ENTRY_TYPE_FORMAT_4_ACTION,
+
 	/** SRAM Action Encap 8 Bytes */
 	CFA_P4_ACTION_SRAM_ENTRY_TYPE_ENCAP_8B,
 	/** SRAM Action Encap 16 Bytes */
 	CFA_P4_ACTION_SRAM_ENTRY_TYPE_ENCAP_16B,
 	/** SRAM Action Encap 64 Bytes */
 	CFA_P4_ACTION_SRAM_ENTRY_TYPE_ENCAP_64B,
+
+	CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_PORT_SRC,
+	CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_PORT_DEST,
+
 	/** SRAM Action Modify IPv4 Source */
 	CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_IPV4_SRC,
 	/** SRAM Action Modify IPv4 Destination */
 	CFA_P4_ACTION_SRAM_ENTRY_TYPE_MODIFY_IPV4_DEST,
+
 	/** SRAM Action Source Properties SMAC */
 	CFA_P4_ACTION_SRAM_ENTRY_TYPE_SP_SMAC,
 	/** SRAM Action Source Properties SMAC IPv4 */
drivers/net/bnxt/meson.build +1 -1
index 7f3ec6204..f25a9448d 100644
@@ -43,7 +43,7 @@ sources = files('bnxt_cpr.c',
 	'tf_core/tf_shadow_tcam.c',
 	'tf_core/tf_tcam.c',
 	'tf_core/tf_util.c',
-	'tf_core/tf_rm.c',
+	'tf_core/tf_if_tbl.c',
 
 	'hcapi/hcapi_cfa_p4.c',
 
drivers/net/bnxt/tf_core/Makefile +2 -0
index 9ba60e1c2..1924bef02 100644
@@ -25,6 +25,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_shadow_tbl.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_shadow_tcam.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_tcam.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_util.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_if_tbl.c
 
 SYMLINK-$(CONFIG_RTE_LIBRTE_BNXT_PMD)-include += tf_core/tf_core.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_BNXT_PMD)-include += tf_core/tf_project.h
@@ -33,3 +34,4 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_BNXT_PMD)-include += tf_core/tf_identifier.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_BNXT_PMD)-include += tf_core/tf_tbl.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_BNXT_PMD)-include += tf_core/stack.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_BNXT_PMD)-include += tf_core/tf_tcam.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_BNXT_PMD)-include += tf_core/tf_if_tbl.h
drivers/net/bnxt/tf_core/hwrm_tf.h +61 -2

85 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_core.c +116 -0

119 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_core.h +104 -0

108 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_device.c +21 -0
index 20b0c5948..a3073c826 100644
@@ -44,6 +44,7 @@ tf_dev_bind_p4(struct tf *tfp,
 	struct tf_tbl_cfg_parms tbl_cfg;
 	struct tf_tcam_cfg_parms tcam_cfg;
 	struct tf_em_cfg_parms em_cfg;
+	struct tf_if_tbl_cfg_parms if_tbl_cfg;
 
 	dev_handle->type = TF_DEVICE_TYPE_WH;
 	/* Initial function initialization */
@@ -114,6 +115,19 @@ tf_dev_bind_p4(struct tf *tfp,
 		goto fail;
 	}
 
+	/*
+	 * IF_TBL
+	 */
+	if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX;
+	if_tbl_cfg.cfg = tf_if_tbl_p4;
+	if_tbl_cfg.shadow_copy = shadow_copy;
+	rc = tf_if_tbl_bind(tfp, &if_tbl_cfg);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "IF Table initialization failure\n");
+		goto fail;
+	}
+
 	/* Final function initialization */
 	dev_handle->ops = &tf_dev_ops_p4;
 
@@ -186,6 +200,13 @@ tf_dev_unbind_p4(struct tf *tfp)
 		fail = true;
 	}
 
+	rc = tf_if_tbl_unbind(tfp);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Device unbind failed, IF Table Type\n");
+		fail = true;
+	}
+
 	if (fail)
 		return -1;
 
drivers/net/bnxt/tf_core/tf_device.h +39 -0
index 58b7a4ab2..5a0943ad7 100644
@@ -10,6 +10,7 @@
 #include "tf_identifier.h"
 #include "tf_tbl.h"
 #include "tf_tcam.h"
+#include "tf_if_tbl.h"
 
 struct tf;
 struct tf_session;
@@ -567,6 +568,44 @@ struct tf_dev_ops {
 	 */
 	int (*tf_dev_free_tbl_scope)(struct tf *tfp,
 				     struct tf_free_tbl_scope_parms *parms);
+
+	/**
+	 * Sets the specified interface table type element.
+	 *
+	 * This API sets the specified element data by invoking the
+	 * firmware.
+	 *
+	 * [in] tfp
+	 *   Pointer to TF handle
+	 *
+	 * [in] parms
+	 *   Pointer to interface table set parameters
+	 *
+	 * Returns
+	 *   - (0) if successful.
+	 *   - (-EINVAL) on failure.
+	 */
+	int (*tf_dev_set_if_tbl)(struct tf *tfp,
+				 struct tf_if_tbl_set_parms *parms);
+
+	/**
+	 * Retrieves the specified interface table type element.
+	 *
+	 * This API retrieves the specified element data by invoking the
+	 * firmware.
+	 *
+	 * [in] tfp
+	 *   Pointer to TF handle
+	 *
+	 * [in] parms
+	 *   Pointer to table get parameters
+	 *
+	 * Returns
+	 *   - (0) if successful.
+	 *   - (-EINVAL) on failure.
+	 */
+	int (*tf_dev_get_if_tbl)(struct tf *tfp,
+				 struct tf_if_tbl_get_parms *parms);
 };
 
 /**
drivers/net/bnxt/tf_core/tf_device_p4.c +5 -0
index 9a3230787..2dc34b853 100644
@@ -11,6 +11,7 @@
 #include "tf_tbl.h"
 #include "tf_tcam.h"
 #include "tf_em.h"
+#include "tf_if_tbl.h"
 
 /**
  * Device specific function that retrieves the MAX number of HCAPI
@@ -105,6 +106,8 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
 	.tf_dev_delete_ext_em_entry = NULL,
 	.tf_dev_alloc_tbl_scope = NULL,
 	.tf_dev_free_tbl_scope = NULL,
+	.tf_dev_set_if_tbl = NULL,
+	.tf_dev_get_if_tbl = NULL,
 };
 
 /**
@@ -135,4 +138,6 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_delete_ext_em_entry = tf_em_delete_ext_entry,
 	.tf_dev_alloc_tbl_scope = tf_em_ext_common_alloc,
 	.tf_dev_free_tbl_scope = tf_em_ext_common_free,
+	.tf_dev_set_if_tbl = tf_if_tbl_set,
+	.tf_dev_get_if_tbl = tf_if_tbl_get,
 };
drivers/net/bnxt/tf_core/tf_device_p4.h +10 -0
index 298e100f3..3b03a7c4e 100644
@@ -10,6 +10,7 @@
 
 #include "tf_core.h"
 #include "tf_rm.h"
+#include "tf_if_tbl.h"
 
 struct tf_rm_element_cfg tf_ident_p4[TF_IDENT_TYPE_MAX] = {
 	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP },
@@ -86,4 +87,13 @@ struct tf_rm_element_cfg tf_em_int_p4[TF_EM_TBL_TYPE_MAX] = {
 	{ TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
 };
 
+struct tf_if_tbl_cfg tf_if_tbl_p4[TF_IF_TBL_TYPE_MAX] = {
+	{ TF_IF_TBL_CFG, CFA_P4_TBL_PROF_SPIF_DFLT_L2CTXT },
+	{ TF_IF_TBL_CFG, CFA_P4_TBL_PROF_PARIF_DFLT_ACT_REC_PTR },
+	{ TF_IF_TBL_CFG, CFA_P4_TBL_PROF_PARIF_ERR_ACT_REC_PTR },
+	{ TF_IF_TBL_CFG, CFA_P4_TBL_LKUP_PARIF_DFLT_ACT_REC_PTR },
+	{ TF_IF_TBL_CFG_NULL, CFA_IF_TBL_TYPE_INVALID },
+	{ TF_IF_TBL_CFG_NULL, CFA_IF_TBL_TYPE_INVALID }
+};
+
 #endif /* _TF_DEVICE_P4_H_ */
drivers/net/bnxt/tf_core/tf_em_common.c +2 -3
index 39a8412b3..23a7fc9c2 100644
@@ -337,11 +337,10 @@ tf_em_ext_common_bind(struct tf *tfp,
 		db_exists = 1;
 	}
 
-	if (db_exists) {
-		mem_type = parms->mem_type;
+	if (db_exists)
 		init = 1;
-	}
 
+	mem_type = parms->mem_type;
 	return 0;
 }
 
drivers/net/bnxt/tf_core/tf_em_host.c +7 -5
index d7c147a15..2626a59fe 100644
@@ -831,7 +831,8 @@ tf_insert_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
 	op.opcode = HCAPI_CFA_HWOPS_ADD;
 	key_tbl.base0 = (uint8_t *)
 		&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_KEY0_TABLE];
-	key_obj.offset = (index * TF_EM_KEY_RECORD_SIZE) % TF_EM_PAGE_SIZE;
+	key_tbl.page_size = TF_EM_PAGE_SIZE;
+	key_obj.offset = index * TF_EM_KEY_RECORD_SIZE;
 	key_obj.data = (uint8_t *)&key_entry;
 	key_obj.size = TF_EM_KEY_RECORD_SIZE;
 
@@ -847,8 +848,7 @@ tf_insert_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
 
 		key_tbl.base0 = (uint8_t *)
 		&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_KEY1_TABLE];
-		key_obj.offset =
-			(index * TF_EM_KEY_RECORD_SIZE) % TF_EM_PAGE_SIZE;
+		key_obj.offset = index * TF_EM_KEY_RECORD_SIZE;
 
 		rc = hcapi_cfa_key_hw_op(&op,
 					 &key_tbl,
@@ -914,7 +914,8 @@ tf_delete_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
 	&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[(hash_type == 0 ?
 							  TF_KEY0_TABLE :
 							  TF_KEY1_TABLE)];
-	key_obj.offset = (index * TF_EM_KEY_RECORD_SIZE) % TF_EM_PAGE_SIZE;
+	key_tbl.page_size = TF_EM_PAGE_SIZE;
+	key_obj.offset = index * TF_EM_KEY_RECORD_SIZE;
 	key_obj.data = NULL;
 	key_obj.size = TF_EM_KEY_RECORD_SIZE;
 
@@ -1195,7 +1196,8 @@ int tf_tbl_ext_host_set(struct tf *tfp,
 	op.opcode = HCAPI_CFA_HWOPS_PUT;
 	key_tbl.base0 =
 		(uint8_t *)&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_RECORD_TABLE];
-	key_obj.offset = parms->idx % TF_EM_PAGE_SIZE;
+	key_tbl.page_size = TF_EM_PAGE_SIZE;
+	key_obj.offset = parms->idx;
 	key_obj.data = parms->data;
 	key_obj.size = parms->data_sz_in_bytes;
 
drivers/net/bnxt/tf_core/tf_identifier.c +1 -2
index 2cc43b40f..90aeaa468 100644
@@ -68,7 +68,7 @@ tf_ident_bind(struct tf *tfp,
 int
 tf_ident_unbind(struct tf *tfp)
 {
-	int rc;
+	int rc = 0;
 	int i;
 	struct tf_rm_free_db_parms fparms = { 0 };
 
@@ -89,7 +89,6 @@ tf_ident_unbind(struct tf *tfp)
 			TFP_DRV_LOG(ERR,
 				    "rm free failed on unbind\n");
 		}
-
 		ident_db[i] = NULL;
 	}
 
drivers/net/bnxt/tf_core/tf_if_tbl.c new file +178 -0

178 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_if_tbl.h new file +236 -0

236 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_msg.c +155 -31

270 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_msg.h +30 -0
index 7432873d7..37f291016 100644
@@ -428,4 +428,34 @@ int tf_msg_bulk_get_tbl_entry(struct tf *tfp,
 			      uint16_t entry_sz_in_bytes,
 			      uint64_t physical_mem_addr);
 
+/**
+ * Sends Set message of a IF Table Type element to the firmware.
+ *
+ * [in] tfp
+ *   Pointer to session handle
+ *
+ * [in] parms
+ *   Pointer to IF table set parameters
+ *
+ * Returns:
+ *  0 on Success else internal Truflow error
+ */
+int tf_msg_set_if_tbl_entry(struct tf *tfp,
+			    struct tf_if_tbl_set_parms *params);
+
+/**
+ * Sends get message of a IF Table Type element to the firmware.
+ *
+ * [in] tfp
+ *   Pointer to session handle
+ *
+ * [in] parms
+ *   Pointer to IF table get parameters
+ *
+ * Returns:
+ *  0 on Success else internal Truflow error
+ */
+int tf_msg_get_if_tbl_entry(struct tf *tfp,
+			    struct tf_if_tbl_get_parms *params);
+
 #endif  /* _TF_MSG_H_ */
drivers/net/bnxt/tf_core/tf_session.c +12 -2
index b08d06306..529ea5083 100644
@@ -70,14 +70,24 @@ tf_session_open_session(struct tf *tfp,
 		goto cleanup;
 	}
 	tfp->session->core_data = cparms.mem_va;
+	session_id = &parms->open_cfg->session_id;
+
+	/* Update Session Info, which is what is visible to the caller */
+	tfp->session->ver.major = 0;
+	tfp->session->ver.minor = 0;
+	tfp->session->ver.update = 0;
 
-	/* Initialize Session and Device */
+	tfp->session->session_id.internal.domain = session_id->internal.domain;
+	tfp->session->session_id.internal.bus = session_id->internal.bus;
+	tfp->session->session_id.internal.device = session_id->internal.device;
+	tfp->session->session_id.internal.fw_session_id = fw_session_id;
+
+	/* Initialize Session and Device, which is private */
 	session = (struct tf_session *)tfp->session->core_data;
 	session->ver.major = 0;
 	session->ver.minor = 0;
 	session->ver.update = 0;
 
-	session_id = &parms->open_cfg->session_id;
 	session->session_id.internal.domain = session_id->internal.domain;
 	session->session_id.internal.bus = session_id->internal.bus;
 	session->session_id.internal.device = session_id->internal.device;
Signature · 1 line
2.21.1 (Apple Git-122.3)
#186 lore raw

PATCH v4 29/51 net/bnxt: add TF register and unregister

In reply to Ajit Khaparde

From: Michael Wildt <[email protected]>

- Add TF register/unregister support. Session got session clients to keep track of the ctrl-channels/function.
- Add support code to tfp layer

---
 drivers/net/bnxt/meson.build          |   1 +
 drivers/net/bnxt/tf_core/Makefile     |   1 +
 drivers/net/bnxt/tf_core/ll.c         |  52 +++
 drivers/net/bnxt/tf_core/ll.h         |  46 +++
 drivers/net/bnxt/tf_core/tf_core.c    |  26 +-
 drivers/net/bnxt/tf_core/tf_core.h    | 105 +++--
 drivers/net/bnxt/tf_core/tf_msg.c     |  84 +++-
 drivers/net/bnxt/tf_core/tf_msg.h     |  42 +-
 drivers/net/bnxt/tf_core/tf_rm.c      |   2 +-
 drivers/net/bnxt/tf_core/tf_session.c | 569 ++++++++++++++++++++++++--
 drivers/net/bnxt/tf_core/tf_session.h | 201 ++++++++-
 drivers/net/bnxt/tf_core/tf_tbl.c     |   2 +
 drivers/net/bnxt/tf_core/tf_tcam.c    |   8 +-
 drivers/net/bnxt/tf_core/tfp.c        |  17 +
 drivers/net/bnxt/tf_core/tfp.h        |  15 +
 15 files changed, 1075 insertions(+), 96 deletions(-)
 create mode 100644 drivers/net/bnxt/tf_core/ll.c
 create mode 100644 drivers/net/bnxt/tf_core/ll.h
drivers/net/bnxt/meson.build +1 -0
index f25a9448d..54564e02e 100644
@@ -44,6 +44,7 @@ sources = files('bnxt_cpr.c',
 	'tf_core/tf_tcam.c',
 	'tf_core/tf_util.c',
 	'tf_core/tf_if_tbl.c',
+	'tf_core/ll.c',
 
 	'hcapi/hcapi_cfa_p4.c',
 
drivers/net/bnxt/tf_core/Makefile +1 -0
index 1924bef02..6210bc70e 100644
@@ -8,6 +8,7 @@
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/bitalloc.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/rand.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/stack.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/ll.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_core.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_rm.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tfp.c
drivers/net/bnxt/tf_core/ll.c new file +52 -0

52 lines not on this page · raw message

drivers/net/bnxt/tf_core/ll.h new file +46 -0

46 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_core.c +11 -15
index a980a2056..489c461d1 100644
@@ -58,21 +58,20 @@ tf_open_session(struct tf *tfp,
 	parms->session_id.internal.device = device;
 	oparms.open_cfg = parms;
 
+	/* Session vs session client is decided in
+	 * tf_session_open_session()
+	 */
+	printf("TF_OPEN, %s\n", parms->ctrl_chan_name);
 	rc = tf_session_open_session(tfp, &oparms);
 	/* Logging handled by tf_session_open_session */
 	if (rc)
 		return rc;
 
 	TFP_DRV_LOG(INFO,
-		    "Session created, session_id:%d\n",
-		    parms->session_id.id);
-
-	TFP_DRV_LOG(INFO,
-		    "domain:%d, bus:%d, device:%d, fw_session_id:%d\n",
+		    "domain:%d, bus:%d, device:%d\n",
 		    parms->session_id.internal.domain,
 		    parms->session_id.internal.bus,
-		    parms->session_id.internal.device,
-		    parms->session_id.internal.fw_session_id);
+		    parms->session_id.internal.device);
 
 	return 0;
 }
@@ -152,6 +151,9 @@ tf_close_session(struct tf *tfp)
 
 	cparms.ref_count = &ref_count;
 	cparms.session_id = &session_id;
+	/* Session vs session client is decided in
+	 * tf_session_close_session()
+	 */
 	rc = tf_session_close_session(tfp,
 				      &cparms);
 	/* Logging handled by tf_session_close_session */
@@ -159,16 +161,10 @@ tf_close_session(struct tf *tfp)
 		return rc;
 
 	TFP_DRV_LOG(INFO,
-		    "Closed session, session_id:%d, ref_count:%d\n",
-		    cparms.session_id->id,
-		    *cparms.ref_count);
-
-	TFP_DRV_LOG(INFO,
-		    "domain:%d, bus:%d, device:%d, fw_session_id:%d\n",
+		    "domain:%d, bus:%d, device:%d\n",
 		    cparms.session_id->internal.domain,
 		    cparms.session_id->internal.bus,
-		    cparms.session_id->internal.device,
-		    cparms.session_id->internal.fw_session_id);
+		    cparms.session_id->internal.device);
 
 	return rc;
 }
drivers/net/bnxt/tf_core/tf_core.h +80 -25

176 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_msg.c +82 -2

102 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_msg.h +41 -1

60 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_rm.c +1 -1
index 30313e2ea..fdb87ecb8 100644
@@ -389,7 +389,7 @@ tf_rm_create_db(struct tf *tfp,
 	TF_CHECK_PARMS2(tfp, parms);
 
 	/* Retrieve the session information */
-	rc = tf_session_get_session(tfp, &tfs);
+	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc)
 		return rc;
 
drivers/net/bnxt/tf_core/tf_session.c +537 -32

671 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_session.h +184 -17

291 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_tbl.c +2 -0
index 7d4daaf2d..2b4a7c561 100644
@@ -269,6 +269,7 @@ tf_tbl_set(struct tf *tfp,
 			    tf_dir_2_str(parms->dir),
 			    parms->type,
 			    strerror(-rc));
+		return rc;
 	}
 
 	return 0;
@@ -338,6 +339,7 @@ tf_tbl_get(struct tf *tfp,
 			    tf_dir_2_str(parms->dir),
 			    parms->type,
 			    strerror(-rc));
+		return rc;
 	}
 
 	return 0;
drivers/net/bnxt/tf_core/tf_tcam.c +5 -3
index 1c48b5363..cbfaa94ee 100644
@@ -138,7 +138,7 @@ tf_tcam_alloc(struct tf *tfp,
 	}
 
 	/* Retrieve the session information */
-	rc = tf_session_get_session(tfp, &tfs);
+	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc)
 		return rc;
 
@@ -218,7 +218,7 @@ tf_tcam_free(struct tf *tfp,
 	}
 
 	/* Retrieve the session information */
-	rc = tf_session_get_session(tfp, &tfs);
+	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc)
 		return rc;
 
@@ -319,6 +319,7 @@ tf_tcam_free(struct tf *tfp,
 			    tf_tcam_tbl_2_str(parms->type),
 			    parms->idx,
 			    strerror(-rc));
+		return rc;
 	}
 
 	return 0;
@@ -353,7 +354,7 @@ tf_tcam_set(struct tf *tfp __rte_unused,
 	}
 
 	/* Retrieve the session information */
-	rc = tf_session_get_session(tfp, &tfs);
+	rc = tf_session_get_session_internal(tfp, &tfs);
 	if (rc)
 		return rc;
 
@@ -415,6 +416,7 @@ tf_tcam_set(struct tf *tfp __rte_unused,
 			    tf_tcam_tbl_2_str(parms->type),
 			    parms->idx,
 			    strerror(-rc));
+		return rc;
 	}
 
 	return 0;
drivers/net/bnxt/tf_core/tfp.c +17 -0
index 69d1c9a1f..426a182a9 100644
@@ -161,3 +161,20 @@ tfp_spinlock_unlock(struct tfp_spinlock_parms *parms)
 {
 	rte_spinlock_unlock(&parms->slock);
 }
+
+int
+tfp_get_fid(struct tf *tfp, uint16_t *fw_fid)
+{
+	struct bnxt *bp = NULL;
+
+	if (tfp == NULL || fw_fid == NULL)
+		return -EINVAL;
+
+	bp = container_of(tfp, struct bnxt, tfp);
+	if (bp == NULL)
+		return -EINVAL;
+
+	*fw_fid = bp->fw_fid;
+
+	return 0;
+}
drivers/net/bnxt/tf_core/tfp.h +15 -0
index fe49b6304..8789eba1f 100644
@@ -238,4 +238,19 @@ int tfp_get_fid(struct tf *tfp, uint16_t *fw_fid);
 #define tfp_bswap_32(val) rte_bswap32(val)
 #define tfp_bswap_64(val) rte_bswap64(val)
 
+/**
+ * Lookup of the FID in the platform specific structure.
+ *
+ * [in] session
+ *   Pointer to session handle
+ *
+ * [out] fw_fid
+ *   Pointer to the fw_fid
+ *
+ * Returns:
+ *   0       - Success
+ *   -EINVAL - Parameter error
+ */
+int tfp_get_fid(struct tf *tfp, uint16_t *fw_fid);
+
 #endif /* _TFP_H_ */
Signature · 1 line
2.21.1 (Apple Git-122.3)
#187 lore raw

PATCH v4 30/51 net/bnxt: add global config set and get APIs

In reply to Ajit Khaparde

From: Jay Ding <[email protected]>

- Add support to update global configuration for ACT_TECT and ACT_ABCR.
- Add support to allow Tunnel and Action global configuration.
- Remove register read and write operations.
- Remove the register read and write support.

---
 drivers/net/bnxt/hcapi/hcapi_cfa.h       |   3 +
 drivers/net/bnxt/meson.build             |   1 +
 drivers/net/bnxt/tf_core/Makefile        |   2 +
 drivers/net/bnxt/tf_core/hwrm_tf.h       |  54 +++++-
 drivers/net/bnxt/tf_core/tf_core.c       | 137 ++++++++++++++++
 drivers/net/bnxt/tf_core/tf_core.h       |  77 +++++++++
 drivers/net/bnxt/tf_core/tf_device.c     |  20 +++
 drivers/net/bnxt/tf_core/tf_device.h     |  33 ++++
 drivers/net/bnxt/tf_core/tf_device_p4.c  |   4 +
 drivers/net/bnxt/tf_core/tf_device_p4.h  |   5 +
 drivers/net/bnxt/tf_core/tf_global_cfg.c | 199 +++++++++++++++++++++++
 drivers/net/bnxt/tf_core/tf_global_cfg.h | 170 +++++++++++++++++++
 drivers/net/bnxt/tf_core/tf_msg.c        | 109 ++++++++++++-
 drivers/net/bnxt/tf_core/tf_msg.h        |  31 ++++
 14 files changed, 840 insertions(+), 5 deletions(-)
 create mode 100644 drivers/net/bnxt/tf_core/tf_global_cfg.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_global_cfg.h
drivers/net/bnxt/hcapi/hcapi_cfa.h +3 -0
index 7a67493bd..3d895f088 100644
@@ -245,6 +245,9 @@ int hcapi_cfa_p4_wc_tcam_rec_hwop(struct hcapi_cfa_hwop *op,
 				   struct hcapi_cfa_data *obj_data);
 int hcapi_cfa_p4_mirror_hwop(struct hcapi_cfa_hwop *op,
 			     struct hcapi_cfa_data *mirror);
+int hcapi_cfa_p4_global_cfg_hwop(struct hcapi_cfa_hwop *op,
+				 uint32_t type,
+				 struct hcapi_cfa_data *config);
 #endif /* SUPPORT_CFA_HW_P4 */
 /**
  *  HCAPI CFA device HW operation function callback definition
drivers/net/bnxt/meson.build +1 -0
index 54564e02e..ace7353be 100644
@@ -45,6 +45,7 @@ sources = files('bnxt_cpr.c',
 	'tf_core/tf_util.c',
 	'tf_core/tf_if_tbl.c',
 	'tf_core/ll.c',
+	'tf_core/tf_global_cfg.c',
 
 	'hcapi/hcapi_cfa_p4.c',
 
drivers/net/bnxt/tf_core/Makefile +2 -0
index 6210bc70e..202db4150 100644
@@ -27,6 +27,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_shadow_tcam.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_tcam.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_util.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_if_tbl.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_global_cfg.c
 
 SYMLINK-$(CONFIG_RTE_LIBRTE_BNXT_PMD)-include += tf_core/tf_core.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_BNXT_PMD)-include += tf_core/tf_project.h
@@ -36,3 +37,4 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_BNXT_PMD)-include += tf_core/tf_tbl.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_BNXT_PMD)-include += tf_core/stack.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_BNXT_PMD)-include += tf_core/tf_tcam.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_BNXT_PMD)-include += tf_core/tf_if_tbl.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_BNXT_PMD)-include += tf_core/tf_global_cfg.h
drivers/net/bnxt/tf_core/hwrm_tf.h +51 -3

77 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_core.c +137 -0

149 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_core.h +77 -0

83 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_device.c +20 -0
index a3073c826..ead958418 100644
@@ -45,6 +45,7 @@ tf_dev_bind_p4(struct tf *tfp,
 	struct tf_tcam_cfg_parms tcam_cfg;
 	struct tf_em_cfg_parms em_cfg;
 	struct tf_if_tbl_cfg_parms if_tbl_cfg;
+	struct tf_global_cfg_cfg_parms global_cfg;
 
 	dev_handle->type = TF_DEVICE_TYPE_WH;
 	/* Initial function initialization */
@@ -128,6 +129,18 @@ tf_dev_bind_p4(struct tf *tfp,
 		goto fail;
 	}
 
+	/*
+	 * GLOBAL_CFG
+	 */
+	global_cfg.num_elements = TF_GLOBAL_CFG_TYPE_MAX;
+	global_cfg.cfg = tf_global_cfg_p4;
+	rc = tf_global_cfg_bind(tfp, &global_cfg);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Global Cfg initialization failure\n");
+		goto fail;
+	}
+
 	/* Final function initialization */
 	dev_handle->ops = &tf_dev_ops_p4;
 
@@ -207,6 +220,13 @@ tf_dev_unbind_p4(struct tf *tfp)
 		fail = true;
 	}
 
+	rc = tf_global_cfg_unbind(tfp);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "Device unbind failed, Global Cfg Type\n");
+		fail = true;
+	}
+
 	if (fail)
 		return -1;
 
drivers/net/bnxt/tf_core/tf_device.h +33 -0
index 5a0943ad7..1740a271f 100644
@@ -11,6 +11,7 @@
 #include "tf_tbl.h"
 #include "tf_tcam.h"
 #include "tf_if_tbl.h"
+#include "tf_global_cfg.h"
 
 struct tf;
 struct tf_session;
@@ -606,6 +607,38 @@ struct tf_dev_ops {
 	 */
 	int (*tf_dev_get_if_tbl)(struct tf *tfp,
 				 struct tf_if_tbl_get_parms *parms);
+
+	/**
+	 * Update global cfg
+	 *
+	 * [in] tfp
+	 *   Pointer to TF handle
+	 *
+	 * [in] parms
+	 *   Pointer to global cfg parameters
+	 *
+	 *    returns:
+	 *    0       - Success
+	 *    -EINVAL - Error
+	 */
+	int (*tf_dev_set_global_cfg)(struct tf *tfp,
+				     struct tf_dev_global_cfg_parms *parms);
+
+	/**
+	 * Get global cfg
+	 *
+	 * [in] tfp
+	 *   Pointer to TF handle
+	 *
+	 * [in] parms
+	 *   Pointer to global cfg parameters
+	 *
+	 *    returns:
+	 *    0       - Success
+	 *    -EINVAL - Error
+	 */
+	int (*tf_dev_get_global_cfg)(struct tf *tfp,
+				     struct tf_dev_global_cfg_parms *parms);
 };
 
 /**
drivers/net/bnxt/tf_core/tf_device_p4.c +4 -0
index 2dc34b853..652608264 100644
@@ -108,6 +108,8 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
 	.tf_dev_free_tbl_scope = NULL,
 	.tf_dev_set_if_tbl = NULL,
 	.tf_dev_get_if_tbl = NULL,
+	.tf_dev_set_global_cfg = NULL,
+	.tf_dev_get_global_cfg = NULL,
 };
 
 /**
@@ -140,4 +142,6 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_free_tbl_scope = tf_em_ext_common_free,
 	.tf_dev_set_if_tbl = tf_if_tbl_set,
 	.tf_dev_get_if_tbl = tf_if_tbl_get,
+	.tf_dev_set_global_cfg = tf_global_cfg_set,
+	.tf_dev_get_global_cfg = tf_global_cfg_get,
 };
drivers/net/bnxt/tf_core/tf_device_p4.h +5 -0
index 3b03a7c4e..7fabb4ba8 100644
@@ -11,6 +11,7 @@
 #include "tf_core.h"
 #include "tf_rm.h"
 #include "tf_if_tbl.h"
+#include "tf_global_cfg.h"
 
 struct tf_rm_element_cfg tf_ident_p4[TF_IDENT_TYPE_MAX] = {
 	{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP },
@@ -96,4 +97,8 @@ struct tf_if_tbl_cfg tf_if_tbl_p4[TF_IF_TBL_TYPE_MAX] = {
 	{ TF_IF_TBL_CFG_NULL, CFA_IF_TBL_TYPE_INVALID }
 };
 
+struct tf_global_cfg_cfg tf_global_cfg_p4[TF_GLOBAL_CFG_TYPE_MAX] = {
+	{ TF_GLOBAL_CFG_CFG_HCAPI, TF_TUNNEL_ENCAP },
+	{ TF_GLOBAL_CFG_CFG_HCAPI, TF_ACTION_BLOCK },
+};
 #endif /* _TF_DEVICE_P4_H_ */
drivers/net/bnxt/tf_core/tf_global_cfg.c new file +199 -0

199 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_global_cfg.h new file +170 -0

170 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_msg.c +107 -2

121 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_msg.h +31 -0
index c02a5203c..195710eb8 100644
@@ -12,6 +12,7 @@
 #include "tf_tbl.h"
 #include "tf_rm.h"
 #include "tf_tcam.h"
+#include "tf_global_cfg.h"
 
 struct tf;
 
@@ -448,6 +449,36 @@ int tf_msg_get_tbl_entry(struct tf *tfp,
 
 /* HWRM Tunneled messages */
 
+/**
+ * Sends global cfg read request to Firmware
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] params
+ *   Pointer to read parameters
+ *
+ * Returns:
+ *   0 on Success else internal Truflow error
+ */
+int tf_msg_get_global_cfg(struct tf *tfp,
+			  struct tf_dev_global_cfg_parms *params);
+
+/**
+ * Sends global cfg update request to Firmware
+ *
+ * [in] tfp
+ *   Pointer to TF handle
+ *
+ * [in] params
+ *   Pointer to write parameters
+ *
+ * Returns:
+ *   0 on Success else internal Truflow error
+ */
+int tf_msg_set_global_cfg(struct tf *tfp,
+			  struct tf_dev_global_cfg_parms *params);
+
 /**
  * Sends bulk get message of a Table Type element to the firmware.
  *
Signature · 1 line
2.21.1 (Apple Git-122.3)
#188 lore raw

PATCH v4 31/51 net/bnxt: add support for EEM System memory

In reply to Ajit Khaparde

From: Peter Spreadborough <[email protected]>

- Select EEM Host or System memory via config parameter
- Add EEM system memory support for kernel memory
- Dependent on DPDK changes that add support for the HWRM_OEM_CMD.

---
 config/common_base                      |   1 +
 drivers/net/bnxt/Makefile               |   3 +
 drivers/net/bnxt/bnxt.h                 |   8 +
 drivers/net/bnxt/bnxt_hwrm.c            |  27 +
 drivers/net/bnxt/bnxt_hwrm.h            |   1 +
 drivers/net/bnxt/meson.build            |   2 +-
 drivers/net/bnxt/tf_core/Makefile       |   5 +-
 drivers/net/bnxt/tf_core/tf_core.c      |  13 +-
 drivers/net/bnxt/tf_core/tf_core.h      |   4 +-
 drivers/net/bnxt/tf_core/tf_device.c    |   5 +-
 drivers/net/bnxt/tf_core/tf_device_p4.c |   2 +-
 drivers/net/bnxt/tf_core/tf_em.h        | 113 +---
 drivers/net/bnxt/tf_core/tf_em_common.c | 683 ++++++++++++++++++++++-
 drivers/net/bnxt/tf_core/tf_em_common.h |  30 ++
 drivers/net/bnxt/tf_core/tf_em_host.c   | 689 +-----------------------
 drivers/net/bnxt/tf_core/tf_em_system.c | 541 ++++++++++++++++---
 drivers/net/bnxt/tf_core/tf_if_tbl.h    |   4 +-
 drivers/net/bnxt/tf_core/tf_msg.c       |  24 +
 drivers/net/bnxt/tf_core/tf_tbl.h       |   7 +
 drivers/net/bnxt/tf_core/tfp.c          |  12 +
 drivers/net/bnxt/tf_core/tfp.h          |  15 +
 21 files changed, 1319 insertions(+), 870 deletions(-)
config/common_base +1 -0
index fe30c515e..370a48f02 100644
@@ -220,6 +220,7 @@ CONFIG_RTE_LIBRTE_BNX2X_DEBUG_PERIODIC=n
 # Compile burst-oriented Broadcom BNXT PMD driver
 #
 CONFIG_RTE_LIBRTE_BNXT_PMD=y
+CONFIG_RTE_LIBRTE_BNXT_PMD_SYSTEM=n
 
 #
 # Compile burst-oriented Chelsio Terminator (CXGBE) PMD
drivers/net/bnxt/Makefile +3 -0
index 349b09c36..6b9544b5d 100644
@@ -50,6 +50,9 @@ CFLAGS += -I$(SRCDIR) -I$(SRCDIR)/tf_ulp -I$(SRCDIR)/tf_core -I$(SRCDIR)/hcapi
 include $(SRCDIR)/tf_ulp/Makefile
 include $(SRCDIR)/tf_core/Makefile
 include $(SRCDIR)/hcapi/Makefile
+ifeq ($(CONFIG_RTE_LIBRTE_BNXT_PMD_SYSTEM), y)
+CFLAGS += -DTF_USE_SYSTEM_MEM
+endif
 endif
 
 #
drivers/net/bnxt/bnxt.h +8 -0
index 65862abdc..43e5e7162 100644
@@ -563,6 +563,13 @@ struct bnxt_rep_info {
 				     DEV_RX_OFFLOAD_SCATTER | \
 				     DEV_RX_OFFLOAD_RSS_HASH)
 
+#define  MAX_TABLE_SUPPORT 4
+#define  MAX_DIR_SUPPORT   2
+struct bnxt_dmabuf_info {
+	uint32_t entry_num;
+	int      fd[MAX_DIR_SUPPORT][MAX_TABLE_SUPPORT];
+};
+
 #define BNXT_HWRM_SHORT_REQ_LEN		sizeof(struct hwrm_short_input)
 
 struct bnxt_flow_stat_info {
@@ -780,6 +787,7 @@ struct bnxt {
 	uint16_t		port_svif;
 
 	struct tf		tfp;
+	struct bnxt_dmabuf_info dmabuf;
 	struct bnxt_ulp_context	*ulp_ctx;
 	struct bnxt_flow_stat_info *flow_stat;
 	uint8_t			flow_xstat;
drivers/net/bnxt/bnxt_hwrm.c +27 -0
index e6a28d07c..2605ef039 100644
@@ -5506,3 +5506,30 @@ int bnxt_hwrm_cfa_counter_qstats(struct bnxt *bp,
 
 	return 0;
 }
+
+#ifdef RTE_LIBRTE_BNXT_PMD_SYSTEM
+int
+bnxt_hwrm_oem_cmd(struct bnxt *bp, uint32_t entry_num)
+{
+	struct hwrm_oem_cmd_input req = {0};
+	struct hwrm_oem_cmd_output *resp = bp->hwrm_cmd_resp_addr;
+	struct bnxt_dmabuf_info oem_data;
+	int rc = 0;
+
+	HWRM_PREP(&req, HWRM_OEM_CMD, BNXT_USE_CHIMP_MB);
+	req.IANA = 0x14e4;
+
+	memset(&oem_data, 0, sizeof(struct bnxt_dmabuf_info));
+	oem_data.entry_num = (entry_num);
+	memcpy(&req.oem_data[0], &oem_data, sizeof(struct bnxt_dmabuf_info));
+
+	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+	HWRM_CHECK_RESULT();
+
+	bp->dmabuf.entry_num = entry_num;
+
+	HWRM_UNLOCK();
+
+	return rc;
+}
+#endif /* RTE_LIBRTE_BNXT_PMD_SYSTEM */
drivers/net/bnxt/bnxt_hwrm.h +1 -0
index 87cd40779..9e0b79904 100644
@@ -276,4 +276,5 @@ int bnxt_hwrm_get_dflt_vnic_svif(struct bnxt *bp, uint16_t fid,
 				 uint16_t *vnic_id, uint16_t *svif);
 int bnxt_hwrm_parent_pf_qcfg(struct bnxt *bp);
 int bnxt_hwrm_port_phy_qcaps(struct bnxt *bp);
+int bnxt_hwrm_oem_cmd(struct bnxt *bp, uint32_t entry_num);
 #endif
drivers/net/bnxt/meson.build +1 -1
index ace7353be..8f6ed419e 100644
@@ -31,7 +31,6 @@ sources = files('bnxt_cpr.c',
         'tf_core/tf_em_common.c',
         'tf_core/tf_em_host.c',
         'tf_core/tf_em_internal.c',
-        'tf_core/tf_em_system.c',
 	'tf_core/tf_rm.c',
 	'tf_core/tf_tbl.c',
 	'tf_core/tfp.c',
@@ -46,6 +45,7 @@ sources = files('bnxt_cpr.c',
 	'tf_core/tf_if_tbl.c',
 	'tf_core/ll.c',
 	'tf_core/tf_global_cfg.c',
+	'tf_core/tf_em_host.c',
 
 	'hcapi/hcapi_cfa_p4.c',
 
drivers/net/bnxt/tf_core/Makefile +4 -1
index 202db4150..750c25c5e 100644
@@ -16,8 +16,11 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_msg.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_tbl.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_em_common.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_em_internal.c
+ifeq ($(CONFIG_RTE_LIBRTE_BNXT_PMD_SYSTEM), n)
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_em_host.c
-SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_em_system.c
+else
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD_SYSTEM) += tf_core/tf_em_system.c
+endif
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_session.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_device.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_device_p4.c
drivers/net/bnxt/tf_core/tf_core.c +10 -3
index 0f119b45f..00b2775ed 100644
@@ -540,10 +540,12 @@ tf_alloc_tcam_entry(struct tf *tfp,
 	int rc;
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
-	struct tf_tcam_alloc_parms aparms = { 0 };
+	struct tf_tcam_alloc_parms aparms;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
+	memset(&aparms, 0, sizeof(struct tf_tcam_alloc_parms));
+
 	/* Retrieve the session information */
 	rc = tf_session_get_session(tfp, &tfs);
 	if (rc) {
@@ -598,10 +600,13 @@ tf_set_tcam_entry(struct tf *tfp,
 	int rc;
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
-	struct tf_tcam_set_parms sparms = { 0 };
+	struct tf_tcam_set_parms sparms;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
+	memset(&sparms, 0, sizeof(struct tf_tcam_set_parms));
+
+
 	/* Retrieve the session information */
 	rc = tf_session_get_session(tfp, &tfs);
 	if (rc) {
@@ -667,10 +672,12 @@ tf_free_tcam_entry(struct tf *tfp,
 	int rc;
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
-	struct tf_tcam_free_parms fparms = { 0 };
+	struct tf_tcam_free_parms fparms;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
+	memset(&fparms, 0, sizeof(struct tf_tcam_free_parms));
+
 	/* Retrieve the session information */
 	rc = tf_session_get_session(tfp, &tfs);
 	if (rc) {
drivers/net/bnxt/tf_core/tf_core.h +2 -2
index 3f54ab16b..9e8042606 100644
@@ -1731,7 +1731,7 @@ struct tf_set_if_tbl_entry_parms {
 	/**
 	 * [in] Entry data
 	 */
-	uint32_t *data;
+	uint8_t *data;
 	/**
 	 * [in] Entry size
 	 */
@@ -1768,7 +1768,7 @@ struct tf_get_if_tbl_entry_parms {
 	/**
 	 * [out] Entry data
 	 */
-	uint32_t *data;
+	uint8_t *data;
 	/**
 	 * [in] Entry size
 	 */
drivers/net/bnxt/tf_core/tf_device.c +4 -1
index ead958418..f08f7eba7 100644
@@ -92,8 +92,11 @@ tf_dev_bind_p4(struct tf *tfp,
 	em_cfg.num_elements = TF_EM_TBL_TYPE_MAX;
 	em_cfg.cfg = tf_em_ext_p4;
 	em_cfg.resources = resources;
+#ifdef TF_USE_SYSTEM_MEM
+	em_cfg.mem_type = TF_EEM_MEM_TYPE_SYSTEM;
+#else
 	em_cfg.mem_type = TF_EEM_MEM_TYPE_HOST;
-
+#endif
 	rc = tf_em_ext_common_bind(tfp, &em_cfg);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
drivers/net/bnxt/tf_core/tf_device_p4.c +1 -1
index 652608264..dfe626c8a 100644
@@ -126,7 +126,7 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
 	.tf_dev_free_ext_tbl = tf_tbl_ext_free,
 	.tf_dev_alloc_search_tbl = NULL,
 	.tf_dev_set_tbl = tf_tbl_set,
-	.tf_dev_set_ext_tbl = tf_tbl_ext_set,
+	.tf_dev_set_ext_tbl = tf_tbl_ext_common_set,
 	.tf_dev_get_tbl = tf_tbl_get,
 	.tf_dev_get_bulk_tbl = tf_tbl_bulk_get,
 	.tf_dev_alloc_tcam = tf_tcam_alloc,
drivers/net/bnxt/tf_core/tf_em.h +22 -91

157 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_em_common.c +663 -20

725 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_em_common.h +30 -0
index bf01df9b8..fa313c458 100644
@@ -101,4 +101,34 @@ void *tf_em_get_table_page(struct tf_tbl_scope_cb *tbl_scope_cb,
 			   uint32_t offset,
 			   enum hcapi_cfa_em_table_type table_type);
 
+/**
+ * Validates EM number of entries requested
+ *
+ * [in] tbl_scope_cb
+ *   Pointer to table scope control block to be populated
+ *
+ * [in] parms
+ *   Pointer to input parameters
+ *
+ * Returns:
+ *   0       - Success
+ *   -EINVAL - Parameter error
+ */
+int tf_em_validate_num_entries(struct tf_tbl_scope_cb *tbl_scope_cb,
+			       struct tf_alloc_tbl_scope_parms *parms);
+
+/**
+ * Size the EM table based on capabilities
+ *
+ * [in] tbl
+ *   EM table to size
+ *
+ * Returns:
+ *   0        - Success
+ *   - EINVAL - Parameter error
+ *   - ENOMEM - Out of memory
+ */
+int tf_em_size_table(struct hcapi_cfa_em_table *tbl,
+		     uint32_t page_size);
+
 #endif /* _TF_EM_COMMON_H_ */
drivers/net/bnxt/tf_core/tf_em_host.c +5 -684

735 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_em_system.c +477 -64

591 lines not on this page · raw message

drivers/net/bnxt/tf_core/tf_if_tbl.h +2 -2
index 54d4c37f5..7eb72bd42 100644
@@ -113,7 +113,7 @@ struct tf_if_tbl_set_parms {
 	/**
 	 * [in] Entry data
 	 */
-	uint32_t *data;
+	uint8_t *data;
 	/**
 	 * [in] Entry size
 	 */
@@ -143,7 +143,7 @@ struct tf_if_tbl_get_parms {
 	/**
 	 * [out] Entry data
 	 */
-	uint32_t *data;
+	uint8_t *data;
 	/**
 	 * [out] Entry size
 	 */
drivers/net/bnxt/tf_core/tf_msg.c +24 -0
index 035c0948d..ed506defa 100644
@@ -813,7 +813,19 @@ tf_msg_tcam_entry_set(struct tf *tfp,
 	struct tf_msg_dma_buf buf = { 0 };
 	uint8_t *data = NULL;
 	int data_size = 0;
+	uint8_t fw_session_id;
 
+	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Unable to lookup FW id, rc:%s\n",
+			    tf_dir_2_str(parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Populate the request */
+	req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
 	req.type = parms->hcapi_type;
 	req.idx = tfp_cpu_to_le_16(parms->idx);
 	if (parms->dir == TF_DIR_TX)
@@ -869,7 +881,19 @@ tf_msg_tcam_entry_free(struct tf *tfp,
 	struct hwrm_tf_tcam_free_input req =  { 0 };
 	struct hwrm_tf_tcam_free_output resp = { 0 };
 	struct tfp_send_msg_parms parms = { 0 };
+	uint8_t fw_session_id;
 
+	rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
+	if (rc) {
+		TFP_DRV_LOG(ERR,
+			    "%s: Unable to lookup FW id, rc:%s\n",
+			    tf_dir_2_str(in_parms->dir),
+			    strerror(-rc));
+		return rc;
+	}
+
+	/* Populate the request */
+	req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
 	req.type = in_parms->hcapi_type;
 	req.count = 1;
 	req.idx_list[0] = tfp_cpu_to_le_16(in_parms->idx);
drivers/net/bnxt/tf_core/tf_tbl.h +7 -0
index 2a10b47ce..f20e8d729 100644
@@ -38,6 +38,13 @@ struct tf_em_caps {
  */
 struct tf_tbl_scope_cb {
 	uint32_t tbl_scope_id;
+#ifdef TF_USE_SYSTEM_MEM
+	int lfc_fd;
+	uint32_t bus;
+	uint32_t devfn;
+	int fd[TF_DIR_MAX][TF_MAX_TABLE];
+	bool valid;
+#endif
 	int index;
 	struct hcapi_cfa_em_ctx_mem_info em_ctx_info[TF_DIR_MAX];
 	struct tf_em_caps em_caps[TF_DIR_MAX];
drivers/net/bnxt/tf_core/tfp.c +12 -0
index 426a182a9..3eade3127 100644
@@ -87,6 +87,18 @@ tfp_send_msg_tunneled(struct tf *tfp,
 	return rc;
 }
 
+#ifdef TF_USE_SYSTEM_MEM
+int
+tfp_msg_hwrm_oem_cmd(struct tf *tfp,
+		     uint32_t max_flows)
+{
+	return bnxt_hwrm_oem_cmd(container_of(tfp,
+					      struct bnxt,
+					      tfp),
+				 max_flows);
+}
+#endif /* TF_USE_SYSTEM_MEM */
+
 /**
  * Allocates zero'ed memory from the heap.
  *
drivers/net/bnxt/tf_core/tfp.h +15 -0
index 8789eba1f..421a7d9f7 100644
@@ -170,6 +170,21 @@ int
 tfp_msg_hwrm_oem_cmd(struct tf *tfp,
 		     uint32_t max_flows);
 
+/**
+ * Sends OEM command message to Chimp
+ *
+ * [in] session, pointer to session handle
+ * [in] max_flows, max number of flows requested
+ *
+ * Returns:
+ *   0              - Success
+ *   -1             - Global error like not supported
+ *   -EINVAL        - Parameter Error
+ */
+int
+tfp_msg_hwrm_oem_cmd(struct tf *tfp,
+		     uint32_t max_flows);
+
 /**
  * Allocates zero'ed memory from the heap.
  *
Signature · 1 line
2.21.1 (Apple Git-122.3)
#189 lore raw

PATCH v4 32/51 net/bnxt: integrate with the latest tf core changes

In reply to Ajit Khaparde

From: Kishore Padmanabha <[email protected]>

ULP changes to integrate with the latest session open interface in tf_core

---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 46 ++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +46 -0
index c7281ab9a..a9ed5d92a 100644
@@ -68,6 +68,7 @@ ulp_ctx_session_open(struct bnxt *bp,
 	struct rte_eth_dev		*ethdev = bp->eth_dev;
 	int32_t				rc = 0;
 	struct tf_open_session_parms	params;
+	struct tf_session_resources	*resources;
 
 	memset(&params, 0, sizeof(params));
 
@@ -79,6 +80,51 @@ ulp_ctx_session_open(struct bnxt *bp,
 		return rc;
 	}
 
+	params.shadow_copy = false;
+	params.device_type = TF_DEVICE_TYPE_WH;
+	resources = &params.resources;
+	/** RX **/
+	/* Identifiers */
+	resources->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_L2_CTXT] = 16;
+	resources->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_WC_PROF] = 8;
+	resources->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_PROF_FUNC] = 8;
+	resources->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_EM_PROF] = 8;
+
+	/* Table Types */
+	resources->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_FULL_ACT_RECORD] = 720;
+	resources->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_ACT_STATS_64] = 720;
+
+	/* TCAMs */
+	resources->tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM] = 16;
+	resources->tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_PROF_TCAM] = 8;
+	resources->tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] = 416;
+
+	/* EM */
+	resources->em_cnt[TF_DIR_RX].cnt[TF_EM_TBL_TYPE_EM_RECORD] = 2048;
+
+	/** TX **/
+	/* Identifiers */
+	resources->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_L2_CTXT] = 8;
+	resources->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_WC_PROF] = 8;
+	resources->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_PROF_FUNC] = 8;
+	resources->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_EM_PROF] = 8;
+
+	/* Table Types */
+	resources->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_FULL_ACT_RECORD] = 16;
+	resources->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_STATS_64] = 16;
+
+	/* TCAMs */
+	resources->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM] = 8;
+	resources->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_PROF_TCAM] = 8;
+	resources->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] = 8;
+
+	/* EM */
+	resources->em_cnt[TF_DIR_TX].cnt[TF_EM_TBL_TYPE_EM_RECORD] = 8;
+
+	/* EEM */
+	resources->em_cnt[TF_DIR_RX].cnt[TF_EM_TBL_TYPE_TBL_SCOPE] = 1;
+	resources->em_cnt[TF_DIR_TX].cnt[TF_EM_TBL_TYPE_TBL_SCOPE] = 1;
+
 	rc = tf_open_session(&bp->tfp, &params);
 	if (rc) {
 		BNXT_TF_DBG(ERR, "Failed to open TF session - %s, rc = %d\n",
Signature · 1 line
2.21.1 (Apple Git-122.3)
#190 lore raw

PATCH v4 33/51 net/bnxt: add support for internal encap records

In reply to Ajit Khaparde

From: Mike Baucom <[email protected]>

Modifications to allow internal encap records to be supported:
- Modified the mapper index table processing to handle encap without an action record
- Modified the session open code to reserve some 64 Byte internal encap records on tx
- Modified the blob encap swap to support encap without action record

---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c   |  3 +++
 drivers/net/bnxt/tf_ulp/ulp_mapper.c | 29 +++++++++++++---------------
 drivers/net/bnxt/tf_ulp/ulp_utils.c  |  2 +-
 3 files changed, 17 insertions(+), 17 deletions(-)
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +3 -0
index a9ed5d92a..4c1a1c44c 100644
@@ -113,6 +113,9 @@ ulp_ctx_session_open(struct bnxt *bp,
 	resources->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_FULL_ACT_RECORD] = 16;
 	resources->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_STATS_64] = 16;
 
+	/* ENCAP */
+	resources->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_ENCAP_64B] = 16;
+
 	/* TCAMs */
 	resources->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM] = 8;
 	resources->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_PROF_TCAM] = 8;
drivers/net/bnxt/tf_ulp/ulp_mapper.c +13 -16
index 734db7c6c..a9a625f9f 100644
@@ -1473,7 +1473,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 		flds = ulp_mapper_act_result_fields_get(tbl, &num_flds,
 							&encap_flds);
 
-	if (!flds || !num_flds) {
+	if (!flds || (!num_flds && !encap_flds)) {
 		BNXT_TF_DBG(ERR, "template undefined for the index table\n");
 		return -EINVAL;
 	}
@@ -1482,7 +1482,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	for (i = 0; i < (num_flds + encap_flds); i++) {
 		/* set the swap index if encap swap bit is enabled */
 		if (parms->device_params->encap_byte_swap && encap_flds &&
-		    ((i + 1) == num_flds))
+		    (i == num_flds))
 			ulp_blob_encap_swap_idx_set(&data);
 
 		/* Process the result fields */
@@ -1495,18 +1495,15 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 			BNXT_TF_DBG(ERR, "data field failed\n");
 			return rc;
 		}
+	}
 
-		/* if encap bit swap is enabled perform the bit swap */
-		if (parms->device_params->encap_byte_swap && encap_flds) {
-			if ((i + 1) == (num_flds + encap_flds))
-				ulp_blob_perform_encap_swap(&data);
+	/* if encap bit swap is enabled perform the bit swap */
+	if (parms->device_params->encap_byte_swap && encap_flds) {
+		ulp_blob_perform_encap_swap(&data);
 #ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-			if ((i + 1) == (num_flds + encap_flds)) {
-				BNXT_TF_DBG(INFO, "Dump fter encap swap\n");
-				ulp_mapper_blob_dump(&data);
-			}
+		BNXT_TF_DBG(INFO, "Dump after encap swap\n");
+		ulp_mapper_blob_dump(&data);
 #endif
-		}
 	}
 
 	/* Perform the tf table allocation by filling the alloc params */
@@ -1817,6 +1814,11 @@ ulp_mapper_action_tbls_process(struct bnxt_ulp_mapper_parms *parms)
 		switch (tbl->resource_func) {
 		case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE:
 			rc = ulp_mapper_index_tbl_process(parms, tbl, false);
+			if (rc) {
+				BNXT_TF_DBG(ERR, "Resource type %d failed\n",
+					    tbl->resource_func);
+				return rc;
+			}
 			break;
 		default:
 			BNXT_TF_DBG(ERR, "Unexpected action resource %d\n",
@@ -1824,11 +1826,6 @@ ulp_mapper_action_tbls_process(struct bnxt_ulp_mapper_parms *parms)
 			return -EINVAL;
 		}
 	}
-	if (rc) {
-		BNXT_TF_DBG(ERR, "Resource type %d failed\n",
-			    tbl->resource_func);
-		return rc;
-	}
 
 	return rc;
 }
drivers/net/bnxt/tf_ulp/ulp_utils.c +1 -1
index 3a4157f22..3afaac647 100644
@@ -478,7 +478,7 @@ ulp_blob_perform_encap_swap(struct ulp_blob *blob)
 		BNXT_TF_DBG(ERR, "invalid argument\n");
 		return; /* failure */
 	}
-	idx = ULP_BITS_2_BYTE_NR(blob->encap_swap_idx + 1);
+	idx = ULP_BITS_2_BYTE_NR(blob->encap_swap_idx);
 	end_idx = ULP_BITS_2_BYTE(blob->write_idx);
 
 	while (idx <= end_idx) {
Signature · 1 line
2.21.1 (Apple Git-122.3)
#191 lore raw

PATCH v4 34/51 net/bnxt: add support for if table processing

In reply to Ajit Khaparde

From: Kishore Padmanabha <[email protected]>

Added support for if table processing in the ulp mapper layer. This enables support for the default partition action record pointer interface table.

---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |   1 +
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c         |   2 +-
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          | 141 +++++++++++++++---
 drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c        |   1 +
 .../net/bnxt/tf_ulp/ulp_template_db_enum.h    | 117 ++++++++-------
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |   8 +-
 6 files changed, 187 insertions(+), 83 deletions(-)
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +1 -0
index 4c1a1c44c..4835b951e 100644
@@ -115,6 +115,7 @@ ulp_ctx_session_open(struct bnxt *bp,
 
 	/* ENCAP */
 	resources->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_ENCAP_64B] = 16;
+	resources->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_ENCAP_16B] = 16;
 
 	/* TCAMs */
 	resources->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM] = 8;
drivers/net/bnxt/tf_ulp/ulp_flow_db.c +1 -1
index 22996e50e..384dc5b2c 100644
@@ -933,7 +933,7 @@ ulp_default_flow_db_cfa_action_get(struct bnxt_ulp_context *ulp_ctx,
 				   uint32_t flow_id,
 				   uint32_t *cfa_action)
 {
-	uint8_t sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_VFR_ACT_IDX;
+	uint8_t sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_VFR_CFA_ACTION;
 	uint64_t hndl;
 	int32_t rc;
 
drivers/net/bnxt/tf_ulp/ulp_mapper.c +118 -23

243 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c +1 -0
index 89c08ab25..517422338 100644
@@ -256,6 +256,7 @@ ulp_mark_db_mark_add(struct bnxt_ulp_context *ctxt,
 			BNXT_TF_DBG(ERR, "Mark index greater than allocated\n");
 			return -EINVAL;
 		}
+		BNXT_TF_DBG(DEBUG, "Set LFID[0x%0x] = 0x%0x\n", fid, mark);
 		mtbl->lfid_tbl[fid].mark_id = mark;
 		ULP_MARK_DB_ENTRY_SET_VALID(&mtbl->lfid_tbl[fid]);
 	}
drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h +61 -56

170 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_template_struct.h +5 -3
index 5c4335847..1188223aa 100644
@@ -150,9 +150,10 @@ struct bnxt_ulp_device_params {
 
 /* Flow Mapper */
 struct bnxt_ulp_mapper_tbl_list_info {
-	uint32_t	device_name;
-	uint32_t	start_tbl_idx;
-	uint32_t	num_tbls;
+	uint32_t		device_name;
+	uint32_t		start_tbl_idx;
+	uint32_t		num_tbls;
+	enum bnxt_ulp_fdb_type	flow_db_table_type;
 };
 
 struct bnxt_ulp_mapper_tbl_info {
@@ -183,6 +184,7 @@ struct bnxt_ulp_mapper_tbl_info {
 
 	enum bnxt_ulp_regfile_index	regfile_idx;
 	enum bnxt_ulp_mark_db_opcode	mark_db_opcode;
+	uint32_t			comp_field_idx;
 };
 
 struct bnxt_ulp_mapper_class_key_field_info {
Signature · 1 line
2.21.1 (Apple Git-122.3)
#192 lore raw

PATCH v4 35/51 net/bnxt: disable Tx vector mode if truflow is enabled

In reply to Ajit Khaparde

From: Kishore Padmanabha <[email protected]>

The vector mode in the tx handler is disabled when truflow is enabled since truflow now requires bd action record support.

---
 drivers/net/bnxt/bnxt_ethdev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/bnxt/bnxt_ethdev.c +4 -1
index 697cd6651..355025741 100644
@@ -1116,12 +1116,15 @@ bnxt_transmit_function(__rte_unused struct rte_eth_dev *eth_dev)
 {
 #ifdef RTE_ARCH_X86
 #ifndef RTE_LIBRTE_IEEE1588
+	struct bnxt *bp = eth_dev->data->dev_private;
+
 	/*
 	 * Vector mode transmit can be enabled only if not using scatter rx
 	 * or tx offloads.
 	 */
 	if (!eth_dev->data->scattered_rx &&
-	    !eth_dev->data->dev_conf.txmode.offloads) {
+	    !eth_dev->data->dev_conf.txmode.offloads &&
+	    !BNXT_TRUFLOW_EN(bp)) {
 		PMD_DRV_LOG(INFO, "Using vector mode transmit for port %d\n",
 			    eth_dev->data->port_id);
 		return bnxt_xmit_pkts_vec;
Signature · 1 line
2.21.1 (Apple Git-122.3)
#193 lore raw

PATCH v4 36/51 net/bnxt: add index opcode and operand to mapper table

In reply to Ajit Khaparde

From: Kishore Padmanabha <[email protected]>

Extended the regfile and computed field operations to a common index opcode operation and added globlal resource operations are also part of the index opcode operation.

---
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          | 56 ++++++++++++++++---
 drivers/net/bnxt/tf_ulp/ulp_template_db_act.c |  9 ++-
 .../net/bnxt/tf_ulp/ulp_template_db_class.c   | 45 +++++----------
 .../net/bnxt/tf_ulp/ulp_template_db_enum.h    |  8 +++
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |  4 +-
 5 files changed, 80 insertions(+), 42 deletions(-)
drivers/net/bnxt/tf_ulp/ulp_mapper.c +49 -7
index 42bb98557..7b3b3d698 100644
@@ -1443,7 +1443,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	struct bnxt_ulp_mapper_result_field_info *flds;
 	struct ulp_flow_db_res_params	fid_parms;
 	struct ulp_blob	data;
-	uint64_t idx;
+	uint64_t idx = 0;
 	uint16_t tmplen;
 	uint32_t i, num_flds;
 	int32_t rc = 0, trc = 0;
@@ -1516,6 +1516,42 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 #endif
 	}
 
+	/*
+	 * Check for index opcode, if it is Global then
+	 * no need to allocate the table, just set the table
+	 * and exit since it is not maintained in the flow db.
+	 */
+	if (tbl->index_opcode == BNXT_ULP_INDEX_OPCODE_GLOBAL) {
+		/* get the index from index operand */
+		if (tbl->index_operand < BNXT_ULP_GLB_REGFILE_INDEX_LAST &&
+		    ulp_mapper_glb_resource_read(parms->mapper_data,
+						 tbl->direction,
+						 tbl->index_operand,
+						 &idx)) {
+			BNXT_TF_DBG(ERR, "Glbl regfile[%d] read failed.\n",
+				    tbl->index_operand);
+			return -EINVAL;
+		}
+		/* set the Tf index table */
+		sparms.dir		= tbl->direction;
+		sparms.type		= tbl->resource_type;
+		sparms.data		= ulp_blob_data_get(&data, &tmplen);
+		sparms.data_sz_in_bytes = ULP_BITS_2_BYTE(tmplen);
+		sparms.idx		= tfp_be_to_cpu_64(idx);
+		sparms.tbl_scope_id	= tbl_scope_id;
+
+		rc = tf_set_tbl_entry(tfp, &sparms);
+		if (rc) {
+			BNXT_TF_DBG(ERR,
+				    "Glbl Set table[%d][%s][%d] failed rc=%d\n",
+				    sparms.type,
+				    (sparms.dir == TF_DIR_RX) ? "RX" : "TX",
+				    sparms.idx,
+				    rc);
+			return rc;
+		}
+		return 0; /* success */
+	}
 	/* Perform the tf table allocation by filling the alloc params */
 	aparms.dir		= tbl->direction;
 	aparms.type		= tbl->resource_type;
@@ -1546,11 +1582,13 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 
 	/* Always storing values in Regfile in BE */
 	idx = tfp_cpu_to_be_64(idx);
-	rc = ulp_regfile_write(parms->regfile, tbl->regfile_idx, idx);
-	if (!rc) {
-		BNXT_TF_DBG(ERR, "Write regfile[%d] failed\n",
-			    tbl->regfile_idx);
-		goto error;
+	if (tbl->index_opcode == BNXT_ULP_INDEX_OPCODE_ALLOCATE) {
+		rc = ulp_regfile_write(parms->regfile, tbl->index_operand, idx);
+		if (!rc) {
+			BNXT_TF_DBG(ERR, "Write regfile[%d] failed\n",
+				    tbl->index_operand);
+			goto error;
+		}
 	}
 
 	/* Perform the tf table set by filling the set params */
@@ -1815,7 +1853,11 @@ ulp_mapper_if_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	}
 
 	/* Get the index details from computed field */
-	idx = ULP_COMP_FLD_IDX_RD(parms, tbl->comp_field_idx);
+	if (tbl->index_opcode != BNXT_ULP_INDEX_OPCODE_COMP_FIELD) {
+		BNXT_TF_DBG(ERR, "Invalid tbl index opcode\n");
+		return -EINVAL;
+	}
+	idx = ULP_COMP_FLD_IDX_RD(parms, tbl->index_operand);
 
 	/* Perform the tf table set by filling the set params */
 	iftbl_params.dir = tbl->direction;
drivers/net/bnxt/tf_ulp/ulp_template_db_act.c +6 -3
index 8af23eff1..9b14fa0bd 100644
@@ -76,7 +76,8 @@ struct bnxt_ulp_mapper_tbl_info ulp_act_tbl_list[] = {
 	.result_bit_size = 128,
 	.result_num_fields = 26,
 	.encap_num_fields = 0,
-	.regfile_idx = BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR,
+	.index_opcode = BNXT_ULP_INDEX_OPCODE_ALLOCATE,
+	.index_operand = BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR,
 	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP
 	},
 	{
@@ -90,7 +91,8 @@ struct bnxt_ulp_mapper_tbl_info ulp_act_tbl_list[] = {
 	.result_bit_size = 128,
 	.result_num_fields = 26,
 	.encap_num_fields = 0,
-	.regfile_idx = BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR,
+	.index_opcode = BNXT_ULP_INDEX_OPCODE_ALLOCATE,
+	.index_operand = BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR,
 	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP
 	},
 	{
@@ -104,7 +106,8 @@ struct bnxt_ulp_mapper_tbl_info ulp_act_tbl_list[] = {
 	.result_bit_size = 128,
 	.result_num_fields = 26,
 	.encap_num_fields = 12,
-	.regfile_idx = BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR,
+	.index_opcode = BNXT_ULP_INDEX_OPCODE_ALLOCATE,
+	.index_operand = BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR,
 	.mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP
 	}
 };
drivers/net/bnxt/tf_ulp/ulp_template_db_class.c +15 -30

135 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h +8 -0
index 66343b918..0215a5dde 100644
@@ -161,6 +161,14 @@ enum bnxt_ulp_hdr_type {
 	BNXT_ULP_HDR_TYPE_LAST = 3
 };
 
+enum bnxt_ulp_index_opcode {
+	BNXT_ULP_INDEX_OPCODE_NOT_USED = 0,
+	BNXT_ULP_INDEX_OPCODE_ALLOCATE = 1,
+	BNXT_ULP_INDEX_OPCODE_GLOBAL = 2,
+	BNXT_ULP_INDEX_OPCODE_COMP_FIELD = 3,
+	BNXT_ULP_INDEX_OPCODE_LAST = 4
+};
+
 enum bnxt_ulp_mapper_opc {
 	BNXT_ULP_MAPPER_OPC_SET_TO_CONSTANT = 0,
 	BNXT_ULP_MAPPER_OPC_SET_TO_HDR_FIELD = 1,
drivers/net/bnxt/tf_ulp/ulp_template_struct.h +2 -2
index 1188223aa..a3ddd33fd 100644
@@ -182,9 +182,9 @@ struct bnxt_ulp_mapper_tbl_info {
 	uint32_t	ident_start_idx;
 	uint16_t	ident_nums;
 
-	enum bnxt_ulp_regfile_index	regfile_idx;
 	enum bnxt_ulp_mark_db_opcode	mark_db_opcode;
-	uint32_t			comp_field_idx;
+	enum bnxt_ulp_index_opcode	index_opcode;
+	uint32_t			index_operand;
 };
 
 struct bnxt_ulp_mapper_class_key_field_info {
Signature · 1 line
2.21.1 (Apple Git-122.3)
#194 lore raw

PATCH v4 37/51 net/bnxt: add support for global resource templates

In reply to Ajit Khaparde

From: Kishore Padmanabha <[email protected]>

Added support for the global resource templates, so that they can be reused by the other regular templates.

---
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          | 178 +++++++++++++++++-
 .../net/bnxt/tf_ulp/ulp_template_db_enum.h    |   1 +
 drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c |   3 +
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |   6 +
 4 files changed, 181 insertions(+), 7 deletions(-)
drivers/net/bnxt/tf_ulp/ulp_mapper.c +171 -7
index 7b3b3d698..6fd55b2a2 100644
@@ -80,15 +80,20 @@ ulp_mapper_glb_resource_write(struct bnxt_ulp_mapper_data *data,
  * returns 0 on success
  */
 static int32_t
-ulp_mapper_resource_ident_allocate(struct tf *tfp,
+ulp_mapper_resource_ident_allocate(struct bnxt_ulp_context *ulp_ctx,
 				   struct bnxt_ulp_mapper_data *mapper_data,
 				   struct bnxt_ulp_glb_resource_info *glb_res)
 {
 	struct tf_alloc_identifier_parms iparms = { 0 };
 	struct tf_free_identifier_parms fparms;
 	uint64_t regval;
+	struct tf *tfp;
 	int32_t rc = 0;
 
+	tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx);
+	if (!tfp)
+		return -EINVAL;
+
 	iparms.ident_type = glb_res->resource_type;
 	iparms.dir = glb_res->direction;
 
@@ -115,13 +120,76 @@ ulp_mapper_resource_ident_allocate(struct tf *tfp,
 		return rc;
 	}
 #ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-	BNXT_TF_DBG(DEBUG, "Allocated Glb Res[%s][%d][%d] = 0x%04x\n",
+	BNXT_TF_DBG(DEBUG, "Allocated Glb Res Ident [%s][%d][%d] = 0x%04x\n",
 		    (iparms.dir == TF_DIR_RX) ? "RX" : "TX",
 		    glb_res->glb_regfile_index, iparms.ident_type, iparms.id);
 #endif
 	return rc;
 }
 
+/*
+ * Internal function to allocate index tbl resource and store it in mapper data.
+ *
+ * returns 0 on success
+ */
+static int32_t
+ulp_mapper_resource_index_tbl_alloc(struct bnxt_ulp_context *ulp_ctx,
+				    struct bnxt_ulp_mapper_data *mapper_data,
+				    struct bnxt_ulp_glb_resource_info *glb_res)
+{
+	struct tf_alloc_tbl_entry_parms	aparms = { 0 };
+	struct tf_free_tbl_entry_parms	free_parms = { 0 };
+	uint64_t regval;
+	struct tf *tfp;
+	uint32_t tbl_scope_id;
+	int32_t rc = 0;
+
+	tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx);
+	if (!tfp)
+		return -EINVAL;
+
+	/* Get the scope id */
+	rc = bnxt_ulp_cntxt_tbl_scope_id_get(ulp_ctx, &tbl_scope_id);
+	if (rc) {
+		BNXT_TF_DBG(ERR, "Failed to get table scope rc=%d\n", rc);
+		return rc;
+	}
+
+	aparms.type = glb_res->resource_type;
+	aparms.dir = glb_res->direction;
+	aparms.search_enable = BNXT_ULP_SEARCH_BEFORE_ALLOC_NO;
+	aparms.tbl_scope_id = tbl_scope_id;
+
+	/* Allocate the index tbl using tf api */
+	rc = tf_alloc_tbl_entry(tfp, &aparms);
+	if (rc) {
+		BNXT_TF_DBG(ERR, "Failed to alloc identifier [%s][%d]\n",
+			    (aparms.dir == TF_DIR_RX) ? "RX" : "TX",
+			    aparms.type);
+		return rc;
+	}
+
+	/* entries are stored as big-endian format */
+	regval = tfp_cpu_to_be_64((uint64_t)aparms.idx);
+	/* write to the mapper global resource */
+	rc = ulp_mapper_glb_resource_write(mapper_data, glb_res, regval);
+	if (rc) {
+		BNXT_TF_DBG(ERR, "Failed to write to global resource id\n");
+		/* Free the identifer when update failed */
+		free_parms.dir = aparms.dir;
+		free_parms.type = aparms.type;
+		free_parms.idx = aparms.idx;
+		tf_free_tbl_entry(tfp, &free_parms);
+		return rc;
+	}
+#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
+	BNXT_TF_DBG(DEBUG, "Allocated Glb Res Index [%s][%d][%d] = 0x%04x\n",
+		    (aparms.dir == TF_DIR_RX) ? "RX" : "TX",
+		    glb_res->glb_regfile_index, aparms.type, aparms.idx);
+#endif
+	return rc;
+}
+
 /* Retrieve the cache initialization parameters for the tbl_idx */
 static struct bnxt_ulp_cache_tbl_params *
 ulp_mapper_cache_tbl_params_get(uint32_t tbl_idx)
@@ -132,6 +200,16 @@ ulp_mapper_cache_tbl_params_get(uint32_t tbl_idx)
 	return &ulp_cache_tbl_params[tbl_idx];
 }
 
+/* Retrieve the global template table */
+static uint32_t *
+ulp_mapper_glb_template_table_get(uint32_t *num_entries)
+{
+	if (!num_entries)
+		return NULL;
+	*num_entries = BNXT_ULP_GLB_TEMPLATE_TBL_MAX_SZ;
+	return ulp_glb_template_tbl;
+}
+
 /*
  * Get the size of the action property for a given index.
  *
@@ -659,7 +737,10 @@ ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
 			return -EINVAL;
 		}
 		act_bit = tfp_be_to_cpu_64(act_bit);
-		act_val = ULP_BITMAP_ISSET(parms->act_bitmap->bits, act_bit);
+		if (ULP_BITMAP_ISSET(parms->act_bitmap->bits, act_bit))
+			act_val = 1;
+		else
+			act_val = 0;
 		if (fld->field_bit_size > ULP_BYTE_2_BITS(sizeof(act_val))) {
 			BNXT_TF_DBG(ERR, "%s field size is incorrect\n", name);
 			return -EINVAL;
@@ -1552,6 +1633,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 		}
 		return 0; /* success */
 	}
+
 	/* Perform the tf table allocation by filling the alloc params */
 	aparms.dir		= tbl->direction;
 	aparms.type		= tbl->resource_type;
@@ -1616,6 +1698,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	fid_parms.direction	= tbl->direction;
 	fid_parms.resource_func	= tbl->resource_func;
 	fid_parms.resource_type	= tbl->resource_type;
+	fid_parms.resource_sub_type = tbl->resource_sub_type;
 	fid_parms.resource_hndl	= aparms.idx;
 	fid_parms.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO;
 
@@ -1884,7 +1967,7 @@ ulp_mapper_if_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 }
 
 static int32_t
-ulp_mapper_glb_resource_info_init(struct tf *tfp,
+ulp_mapper_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx,
 				  struct bnxt_ulp_mapper_data *mapper_data)
 {
 	struct bnxt_ulp_glb_resource_info *glb_res;
@@ -1901,15 +1984,23 @@ ulp_mapper_glb_resource_info_init(struct tf *tfp,
 	for (idx = 0; idx < num_glb_res_ids; idx++) {
 		switch (glb_res[idx].resource_func) {
 		case BNXT_ULP_RESOURCE_FUNC_IDENTIFIER:
-			rc = ulp_mapper_resource_ident_allocate(tfp,
+			rc = ulp_mapper_resource_ident_allocate(ulp_ctx,
 								mapper_data,
 								&glb_res[idx]);
 			break;
+		case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE:
+			rc = ulp_mapper_resource_index_tbl_alloc(ulp_ctx,
+								 mapper_data,
+								 &glb_res[idx]);
+			break;
 		default:
 			BNXT_TF_DBG(ERR, "Global resource %x not supported\n",
 				    glb_res[idx].resource_func);
+			rc = -EINVAL;
 			break;
 		}
+		if (rc)
+			return rc;
 	}
 	return rc;
 }
@@ -2125,7 +2216,9 @@ ulp_mapper_glb_resource_info_deinit(struct bnxt_ulp_context *ulp_ctx,
 			res.resource_func = ent->resource_func;
 			res.direction = dir;
 			res.resource_type = ent->resource_type;
-			res.resource_hndl = ent->resource_hndl;
+			/*convert it from BE to cpu */
+			res.resource_hndl =
+				tfp_be_to_cpu_64(ent->resource_hndl);
 			ulp_mapper_resource_free(ulp_ctx, &res);
 		}
 	}
@@ -2144,6 +2237,71 @@ ulp_mapper_flow_destroy(struct bnxt_ulp_context	*ulp_ctx, uint32_t fid)
 					 BNXT_ULP_REGULAR_FLOW_TABLE);
 }
 
+/* Function to handle the default global templates that are allocated during
+ * the startup and reused later.
+ */
+static int32_t
+ulp_mapper_glb_template_table_init(struct bnxt_ulp_context *ulp_ctx)
+{
+	uint32_t *glbl_tmpl_list;
+	uint32_t num_glb_tmpls, idx, dev_id;
+	struct bnxt_ulp_mapper_parms parms;
+	struct bnxt_ulp_mapper_data *mapper_data;
+	int32_t rc = 0;
+
+	glbl_tmpl_list = ulp_mapper_glb_template_table_get(&num_glb_tmpls);
+	if (!glbl_tmpl_list || !num_glb_tmpls)
+		return rc; /* No global templates to process */
+
+	/* Get the device id from the ulp context */
+	if (bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id)) {
+		BNXT_TF_DBG(ERR, "Invalid ulp context\n");
+		return -EINVAL;
+	}
+
+	mapper_data = bnxt_ulp_cntxt_ptr2_mapper_data_get(ulp_ctx);
+	if (!mapper_data) {
+		BNXT_TF_DBG(ERR, "Failed to get the ulp mapper data\n");
+		return -EINVAL;
+	}
+
+	/* Iterate the global resources and process each one */
+	for (idx = 0; idx < num_glb_tmpls; idx++) {
+		/* Initialize the parms structure */
+		memset(&parms, 0, sizeof(parms));
+		parms.tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx);
+		parms.ulp_ctx = ulp_ctx;
+		parms.dev_id = dev_id;
+		parms.mapper_data = mapper_data;
+
+		/* Get the class table entry from dev id and class id */
+		parms.class_tid = glbl_tmpl_list[idx];
+		parms.ctbls = ulp_mapper_class_tbl_list_get(parms.dev_id,
+							    parms.class_tid,
+							    &parms.num_ctbls,
+							    &parms.tbl_idx);
+		if (!parms.ctbls || !parms.num_ctbls) {
+			BNXT_TF_DBG(ERR, "No class tables for %d:%d\n",
+				    parms.dev_id, parms.class_tid);
+			return -EINVAL;
+		}
+		parms.device_params = bnxt_ulp_device_params_get(parms.dev_id);
+		if (!parms.device_params) {
+			BNXT_TF_DBG(ERR, "No class tables for %d:%d\n",
+				    parms.dev_id, parms.class_tid);
+			return -EINVAL;
+		}
+		rc = ulp_mapper_class_tbls_process(&parms);
+		if (rc) {
+			BNXT_TF_DBG(ERR,
+				    "class tables failed creation for %d:%d\n",
+				    parms.dev_id, parms.class_tid);
+			return rc;
+		}
+	}
+	return rc;
+}
+
 /* Function to handle the mapping of the Flow to be compatible
  * with the underlying hardware.
  */
@@ -2316,7 +2474,7 @@ ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx)
 	}
 
 	/* Allocate the global resource ids */
-	rc = ulp_mapper_glb_resource_info_init(tfp, data);
+	rc = ulp_mapper_glb_resource_info_init(ulp_ctx, data);
 	if (rc) {
 		BNXT_TF_DBG(ERR, "Failed to initialize global resource ids\n");
 		goto error;
@@ -2344,6 +2502,12 @@ ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx)
 		}
 	}
 
+	rc = ulp_mapper_glb_template_table_init(ulp_ctx);
+	if (rc) {
+		BNXT_TF_DBG(ERR, "Failed to initialize global templates\n");
+		goto error;
+	}
+
 	return 0;
 error:
 	/* Ignore the return code in favor of returning the original error. */
drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h +1 -0
index 0215a5dde..7c0dc5ee4 100644
@@ -26,6 +26,7 @@
 #define BNXT_ULP_ACT_HID_MASK 255
 #define BNXT_ULP_CACHE_TBL_IDENT_MAX_NUM 2
 #define BNXT_ULP_GLB_RESOURCE_INFO_TBL_MAX_SZ 3
+#define BNXT_ULP_GLB_TEMPLATE_TBL_MAX_SZ 0
 
 enum bnxt_ulp_action_bit {
 	BNXT_ULP_ACTION_BIT_MARK             = 0x0000000000000001,
drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c +3 -0
index 2efd11447..beca3baa7 100644
@@ -546,3 +546,6 @@ uint32_t bnxt_ulp_encap_vtag_map[] = {
 	[1] = BNXT_ULP_SYM_ECV_VTAG_TYPE_ADD_1_ENCAP_PRI,
 	[2] = BNXT_ULP_SYM_ECV_VTAG_TYPE_ADD_2_ENCAP_PRI
 };
+
+uint32_t ulp_glb_template_tbl[] = {
+};
drivers/net/bnxt/tf_ulp/ulp_template_struct.h +6 -0
index a3ddd33fd..4bcd02ba2 100644
@@ -299,4 +299,10 @@ extern struct bnxt_ulp_glb_resource_info ulp_glb_resource_tbl[];
  */
 extern struct bnxt_ulp_cache_tbl_params ulp_cache_tbl_params[];
 
+/*
+ * The ulp_global template table is used to initialize default entries
+ * that could be reused by other templates.
+ */
+extern uint32_t ulp_glb_template_tbl[];
+
 #endif /* _ULP_TEMPLATE_STRUCT_H_ */
Signature · 1 line
2.21.1 (Apple Git-122.3)
#195 lore raw

PATCH v4 38/51 net/bnxt: add support for internal exact match entries

In reply to Ajit Khaparde

From: Kishore Padmanabha <[email protected]>

Added support for the internal exact match entries.

---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c            | 38 +++++++++++++++++++
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c         | 13 +++++--
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          | 21 ++++++----
 drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c        |  4 ++
 .../net/bnxt/tf_ulp/ulp_template_db_class.c   |  6 +--
 .../net/bnxt/tf_ulp/ulp_template_db_enum.h    | 13 ++++---
 drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c |  7 +++-
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |  5 +++
 8 files changed, 85 insertions(+), 22 deletions(-)
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +38 -0
index 4835b951e..1b52861d4 100644
@@ -213,8 +213,27 @@ static int32_t
 ulp_eem_tbl_scope_init(struct bnxt *bp)
 {
 	struct tf_alloc_tbl_scope_parms params = {0};
+	uint32_t dev_id;
+	struct bnxt_ulp_device_params *dparms;
 	int rc;
 
+	/* Get the dev specific number of flows that needed to be supported. */
+	if (bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &dev_id)) {
+		BNXT_TF_DBG(ERR, "Invalid device id\n");
+		return -EINVAL;
+	}
+
+	dparms = bnxt_ulp_device_params_get(dev_id);
+	if (!dparms) {
+		BNXT_TF_DBG(ERR, "could not fetch the device params\n");
+		return -ENODEV;
+	}
+
+	if (dparms->flow_mem_type != BNXT_ULP_FLOW_MEM_TYPE_EXT) {
+		BNXT_TF_DBG(INFO, "Table Scope alloc is not required\n");
+		return 0;
+	}
+
 	bnxt_init_tbl_scope_parms(bp, &params);
 
 	rc = tf_alloc_tbl_scope(&bp->tfp, &params);
@@ -240,6 +259,8 @@ ulp_eem_tbl_scope_deinit(struct bnxt *bp, struct bnxt_ulp_context *ulp_ctx)
 	struct tf_free_tbl_scope_parms	params = {0};
 	struct tf			*tfp;
 	int32_t				rc = 0;
+	struct bnxt_ulp_device_params *dparms;
+	uint32_t dev_id;
 
 	if (!ulp_ctx || !ulp_ctx->cfg_data)
 		return -EINVAL;
@@ -254,6 +275,23 @@ ulp_eem_tbl_scope_deinit(struct bnxt *bp, struct bnxt_ulp_context *ulp_ctx)
 		return -EINVAL;
 	}
 
+	/* Get the dev specific number of flows that needed to be supported. */
+	if (bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &dev_id)) {
+		BNXT_TF_DBG(ERR, "Invalid device id\n");
+		return -EINVAL;
+	}
+
+	dparms = bnxt_ulp_device_params_get(dev_id);
+	if (!dparms) {
+		BNXT_TF_DBG(ERR, "could not fetch the device params\n");
+		return -ENODEV;
+	}
+
+	if (dparms->flow_mem_type != BNXT_ULP_FLOW_MEM_TYPE_EXT) {
+		BNXT_TF_DBG(INFO, "Table Scope free is not required\n");
+		return 0;
+	}
+
 	rc = bnxt_ulp_cntxt_tbl_scope_id_get(ulp_ctx, &params.tbl_scope_id);
 	if (rc) {
 		BNXT_TF_DBG(ERR, "Failed to get the table scope id\n");
drivers/net/bnxt/tf_ulp/ulp_flow_db.c +9 -4
index 384dc5b2c..7696de2a5 100644
@@ -114,7 +114,8 @@ ulp_flow_db_res_params_to_info(struct ulp_fdb_resource_info *resource_info,
 	}
 
 	/* Store the handle as 64bit only for EM table entries */
-	if (params->resource_func != BNXT_ULP_RESOURCE_FUNC_EM_TABLE) {
+	if (params->resource_func != BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE &&
+	    params->resource_func != BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE) {
 		resource_info->resource_hndl = (uint32_t)params->resource_hndl;
 		resource_info->resource_type = params->resource_type;
 		resource_info->resource_sub_type = params->resource_sub_type;
@@ -145,7 +146,8 @@ ulp_flow_db_res_info_to_params(struct ulp_fdb_resource_info *resource_info,
 	/* use the helper function to get the resource func */
 	params->resource_func = ulp_flow_db_resource_func_get(resource_info);
 
-	if (params->resource_func == BNXT_ULP_RESOURCE_FUNC_EM_TABLE) {
+	if (params->resource_func == BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE ||
+	    params->resource_func == BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE) {
 		params->resource_hndl = resource_info->resource_em_handle;
 	} else if (params->resource_func & ULP_FLOW_DB_RES_FUNC_NEED_LOWER) {
 		params->resource_hndl = resource_info->resource_hndl;
@@ -908,7 +910,9 @@ ulp_flow_db_resource_hndl_get(struct bnxt_ulp_context *ulp_ctx,
 				}
 
 			} else if (resource_func ==
-				   BNXT_ULP_RESOURCE_FUNC_EM_TABLE){
+				   BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE ||
+				   resource_func ==
+				   BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE) {
 				*res_hndl = fid_res->resource_em_handle;
 				return 0;
 			}
@@ -966,7 +970,8 @@ static void ulp_flow_db_res_dump(struct ulp_fdb_resource_info	*r,
 
 	BNXT_TF_DBG(DEBUG, "Resource func = %x, nxt_resource_idx = %x\n",
 		    res_func, (ULP_FLOW_DB_RES_NXT_MASK & r->nxt_resource_idx));
-	if (res_func == BNXT_ULP_RESOURCE_FUNC_EM_TABLE)
+	if (res_func == BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE ||
+	    res_func == BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE)
 		BNXT_TF_DBG(DEBUG, "EM Handle = 0x%016" PRIX64 "\n",
 			    r->resource_em_handle);
 	else
drivers/net/bnxt/tf_ulp/ulp_mapper.c +13 -8
index 6fd55b2a2..e2b771c9f 100644
@@ -556,15 +556,18 @@ ulp_mapper_index_entry_free(struct bnxt_ulp_context *ulp,
 }
 
 static inline int32_t
-ulp_mapper_eem_entry_free(struct bnxt_ulp_context *ulp,
-			  struct tf *tfp,
-			  struct ulp_flow_db_res_params *res)
+ulp_mapper_em_entry_free(struct bnxt_ulp_context *ulp,
+			 struct tf *tfp,
+			 struct ulp_flow_db_res_params *res)
 {
 	struct tf_delete_em_entry_parms fparms = { 0 };
 	int32_t rc;
 
 	fparms.dir		= res->direction;
-	fparms.mem		= TF_MEM_EXTERNAL;
+	if (res->resource_func == BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE)
+		fparms.mem = TF_MEM_EXTERNAL;
+	else
+		fparms.mem = TF_MEM_INTERNAL;
 	fparms.flow_handle	= res->resource_hndl;
 
 	rc = bnxt_ulp_cntxt_tbl_scope_id_get(ulp, &fparms.tbl_scope_id);
@@ -1443,7 +1446,7 @@ ulp_mapper_em_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 #endif
 
 	/* do the transpose for the internal EM keys */
-	if (tbl->resource_type == TF_MEM_INTERNAL)
+	if (tbl->resource_func == BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE)
 		ulp_blob_perform_byte_reverse(&key);
 
 	rc = bnxt_ulp_cntxt_tbl_scope_id_get(parms->ulp_ctx,
@@ -2066,7 +2069,8 @@ ulp_mapper_class_tbls_process(struct bnxt_ulp_mapper_parms *parms)
 		case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE:
 			rc = ulp_mapper_tcam_tbl_process(parms, tbl);
 			break;
-		case BNXT_ULP_RESOURCE_FUNC_EM_TABLE:
+		case BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE:
+		case BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE:
 			rc = ulp_mapper_em_tbl_process(parms, tbl);
 			break;
 		case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE:
@@ -2119,8 +2123,9 @@ ulp_mapper_resource_free(struct bnxt_ulp_context *ulp,
 	case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE:
 		rc = ulp_mapper_tcam_entry_free(ulp, tfp, res);
 		break;
-	case BNXT_ULP_RESOURCE_FUNC_EM_TABLE:
-		rc = ulp_mapper_eem_entry_free(ulp, tfp, res);
+	case BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE:
+	case BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE:
+		rc = ulp_mapper_em_entry_free(ulp, tfp, res);
 		break;
 	case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE:
 		rc = ulp_mapper_index_entry_free(ulp, tfp, res);
drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c +4 -0
index 517422338..b3527eccb 100644
@@ -87,6 +87,9 @@ ulp_mark_db_init(struct bnxt_ulp_context *ctxt)
 
 	/* Need to allocate 2 * Num flows to account for hash type bit */
 	mark_tbl->gfid_num_entries = dparms->mark_db_gfid_entries;
+	if (!mark_tbl->gfid_num_entries)
+		goto gfid_not_required;
+
 	mark_tbl->gfid_tbl = rte_zmalloc("ulp_rx_eem_flow_mark_table",
 					 mark_tbl->gfid_num_entries *
 					 sizeof(struct bnxt_gfid_mark_info),
@@ -109,6 +112,7 @@ ulp_mark_db_init(struct bnxt_ulp_context *ctxt)
 		    mark_tbl->gfid_num_entries - 1,
 		    mark_tbl->gfid_mask);
 
+gfid_not_required:
 	/* Add the mark tbl to the ulp context. */
 	bnxt_ulp_cntxt_ptr2_mark_db_set(ctxt, mark_tbl);
 	return 0;
drivers/net/bnxt/tf_ulp/ulp_template_db_class.c +3 -3
index d4c7bfa4d..8eb559050 100644
@@ -179,7 +179,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO
 	},
 	{
-	.resource_func = BNXT_ULP_RESOURCE_FUNC_EM_TABLE,
+	.resource_func = BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE,
 	.resource_type = TF_MEM_EXTERNAL,
 	.resource_sub_type =
 		BNXT_ULP_RESOURCE_SUB_TYPE_NOT_USED,
@@ -284,7 +284,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO
 	},
 	{
-	.resource_func = BNXT_ULP_RESOURCE_FUNC_EM_TABLE,
+	.resource_func = BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE,
 	.resource_type = TF_MEM_EXTERNAL,
 	.resource_sub_type =
 		BNXT_ULP_RESOURCE_SUB_TYPE_NOT_USED,
@@ -389,7 +389,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
 	.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO
 	},
 	{
-	.resource_func = BNXT_ULP_RESOURCE_FUNC_EM_TABLE,
+	.resource_func = BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE,
 	.resource_type = TF_MEM_EXTERNAL,
 	.resource_sub_type =
 		BNXT_ULP_RESOURCE_SUB_TYPE_NOT_USED,
drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h +7 -6
index 7c0dc5ee4..3168d29a9 100644
@@ -149,10 +149,11 @@ enum bnxt_ulp_flow_mem_type {
 };
 
 enum bnxt_ulp_glb_regfile_index {
-	BNXT_ULP_GLB_REGFILE_INDEX_GLB_PROF_FUNC_ID = 0,
-	BNXT_ULP_GLB_REGFILE_INDEX_GLB_L2_CNTXT_ID = 1,
-	BNXT_ULP_GLB_REGFILE_INDEX_GLB_LOOPBACK_AREC_INDEX = 2,
-	BNXT_ULP_GLB_REGFILE_INDEX_LAST = 3
+	BNXT_ULP_GLB_REGFILE_INDEX_NOT_USED = 0,
+	BNXT_ULP_GLB_REGFILE_INDEX_GLB_PROF_FUNC_ID = 1,
+	BNXT_ULP_GLB_REGFILE_INDEX_GLB_L2_CNTXT_ID = 2,
+	BNXT_ULP_GLB_REGFILE_INDEX_GLB_LB_AREC_PTR = 3,
+	BNXT_ULP_GLB_REGFILE_INDEX_LAST = 4
 };
 
 enum bnxt_ulp_hdr_type {
@@ -257,8 +258,8 @@ enum bnxt_ulp_match_type_bitmask {
 
 enum bnxt_ulp_resource_func {
 	BNXT_ULP_RESOURCE_FUNC_INVALID = 0x00,
-	BNXT_ULP_RESOURCE_FUNC_EM_TABLE = 0x20,
-	BNXT_ULP_RESOURCE_FUNC_RSVD1 = 0x40,
+	BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE = 0x20,
+	BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE = 0x40,
 	BNXT_ULP_RESOURCE_FUNC_RSVD2 = 0x60,
 	BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE = 0x80,
 	BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE = 0x81,
drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c +6 -1
index beca3baa7..7c440e3a4 100644
@@ -321,7 +321,12 @@ struct bnxt_ulp_device_params ulp_device_params[BNXT_ULP_DEVICE_ID_LAST] = {
 	.mark_db_gfid_entries   = 65536,
 	.flow_count_db_entries  = 16384,
 	.num_resources_per_flow = 8,
-	.num_phy_ports          = 2
+	.num_phy_ports          = 2,
+	.ext_cntr_table_type    = 0,
+	.byte_count_mask        = 0x00000003ffffffff,
+	.packet_count_mask      = 0xfffffffc00000000,
+	.byte_count_shift       = 0,
+	.packet_count_shift     = 36
 	}
 };
 
drivers/net/bnxt/tf_ulp/ulp_template_struct.h +5 -0
index 4bcd02ba2..5a7a7b910 100644
@@ -146,6 +146,11 @@ struct bnxt_ulp_device_params {
 	uint64_t			flow_db_num_entries;
 	uint32_t			flow_count_db_entries;
 	uint32_t			num_resources_per_flow;
+	uint32_t			ext_cntr_table_type;
+	uint64_t			byte_count_mask;
+	uint64_t			packet_count_mask;
+	uint32_t			byte_count_shift;
+	uint32_t			packet_count_shift;
 };
 
 /* Flow Mapper */
Signature · 1 line
2.21.1 (Apple Git-122.3)
#196 lore raw

PATCH v4 39/51 net/bnxt: add support for conditional execution of mapper tables

In reply to Ajit Khaparde

From: Kishore Padmanabha <[email protected]>

Added support for conditional execution of the mapper tables so that actions like count will have table processed only if action count is configured.

---
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          | 45 +++++++++++++++++++
 drivers/net/bnxt/tf_ulp/ulp_mapper.h          |  1 +
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c      |  8 ++++
 .../net/bnxt/tf_ulp/ulp_template_db_enum.h    | 12 ++++-
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |  2 +
 5 files changed, 67 insertions(+), 1 deletion(-)
drivers/net/bnxt/tf_ulp/ulp_mapper.c +45 -0
index e2b771c9f..d0931d411 100644
@@ -2008,6 +2008,44 @@ ulp_mapper_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx,
 	return rc;
 }
 
+/*
+ * Function to process the conditional opcode of the mapper table.
+ * returns 1 to skip the table.
+ * return 0 to continue processing the table.
+ */
+static int32_t
+ulp_mapper_tbl_cond_opcode_process(struct bnxt_ulp_mapper_parms *parms,
+				   struct bnxt_ulp_mapper_tbl_info *tbl)
+{
+	int32_t rc = 1;
+
+	switch (tbl->cond_opcode) {
+	case BNXT_ULP_COND_OPCODE_NOP:
+		rc = 0;
+		break;
+	case BNXT_ULP_COND_OPCODE_COMP_FIELD:
+		if (tbl->cond_operand < BNXT_ULP_CF_IDX_LAST &&
+		    ULP_COMP_FLD_IDX_RD(parms, tbl->cond_operand))
+			rc = 0;
+		break;
+	case BNXT_ULP_COND_OPCODE_ACTION_BIT:
+		if (ULP_BITMAP_ISSET(parms->act_bitmap->bits,
+				     tbl->cond_operand))
+			rc = 0;
+		break;
+	case BNXT_ULP_COND_OPCODE_HDR_BIT:
+		if (ULP_BITMAP_ISSET(parms->hdr_bitmap->bits,
+				     tbl->cond_operand))
+			rc = 0;
+		break;
+	default:
+		BNXT_TF_DBG(ERR,
+			    "Invalid arg in mapper tbl for cond opcode\n");
+		break;
+	}
+	return rc;
+}
+
 /*
  * Function to process the action template. Iterate through the list
  * action info templates and process it.
@@ -2027,6 +2065,9 @@ ulp_mapper_action_tbls_process(struct bnxt_ulp_mapper_parms *parms)
 
 	for (i = 0; i < parms->num_atbls; i++) {
 		tbl = &parms->atbls[i];
+		if (ulp_mapper_tbl_cond_opcode_process(parms, tbl))
+			continue;
+
 		switch (tbl->resource_func) {
 		case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE:
 			rc = ulp_mapper_index_tbl_process(parms, tbl, false);
@@ -2065,6 +2106,9 @@ ulp_mapper_class_tbls_process(struct bnxt_ulp_mapper_parms *parms)
 	for (i = 0; i < parms->num_ctbls; i++) {
 		struct bnxt_ulp_mapper_tbl_info *tbl = &parms->ctbls[i];
 
+		if (ulp_mapper_tbl_cond_opcode_process(parms, tbl))
+			continue;
+
 		switch (tbl->resource_func) {
 		case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE:
 			rc = ulp_mapper_tcam_tbl_process(parms, tbl);
@@ -2326,6 +2370,7 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 	memset(&parms, 0, sizeof(parms));
 	parms.act_prop = cparms->act_prop;
 	parms.act_bitmap = cparms->act;
+	parms.hdr_bitmap = cparms->hdr_bitmap;
 	parms.regfile = &regfile;
 	parms.hdr_field = cparms->hdr_field;
 	parms.comp_fld = cparms->comp_fld;
drivers/net/bnxt/tf_ulp/ulp_mapper.h +1 -0
index b159081b1..19134830a 100644
@@ -62,6 +62,7 @@ struct bnxt_ulp_mapper_parms {
 	uint32_t				num_ctbls;
 	struct ulp_rte_act_prop			*act_prop;
 	struct ulp_rte_act_bitmap		*act_bitmap;
+	struct ulp_rte_hdr_bitmap		*hdr_bitmap;
 	struct ulp_rte_hdr_field		*hdr_field;
 	uint32_t				*comp_fld;
 	struct ulp_regfile			*regfile;
drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +8 -0
index 41ac77c6f..8fffaecce 100644
@@ -1128,6 +1128,10 @@ ulp_rte_vxlan_encap_act_handler(const struct rte_flow_action *action_item,
 		memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_L3_TYPE],
 		       &ip_type, sizeof(uint32_t));
 
+		/* update the computed field to notify it is ipv4 header */
+		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_ACT_ENCAP_IPV4_FLAG,
+				    1);
+
 		if (!ulp_rte_item_skip_void(&item, 1))
 			return BNXT_TF_RC_ERROR;
 	} else if (item->type == RTE_FLOW_ITEM_TYPE_IPV6) {
@@ -1148,6 +1152,10 @@ ulp_rte_vxlan_encap_act_handler(const struct rte_flow_action *action_item,
 		memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_L3_TYPE],
 		       &ip_type, sizeof(uint32_t));
 
+		/* update the computed field to notify it is ipv6 header */
+		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_ACT_ENCAP_IPV6_FLAG,
+				    1);
+
 		if (!ulp_rte_item_skip_void(&item, 1))
 			return BNXT_TF_RC_ERROR;
 	} else {
drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h +11 -1
index 3168d29a9..27628a510 100644
@@ -118,7 +118,17 @@ enum bnxt_ulp_cf_idx {
 	BNXT_ULP_CF_IDX_PHY_PORT_SPIF = 26,
 	BNXT_ULP_CF_IDX_PHY_PORT_PARIF = 27,
 	BNXT_ULP_CF_IDX_PHY_PORT_VPORT = 28,
-	BNXT_ULP_CF_IDX_LAST = 29
+	BNXT_ULP_CF_IDX_ACT_ENCAP_IPV4_FLAG = 29,
+	BNXT_ULP_CF_IDX_ACT_ENCAP_IPV6_FLAG = 30,
+	BNXT_ULP_CF_IDX_LAST = 31
+};
+
+enum bnxt_ulp_cond_opcode {
+	BNXT_ULP_COND_OPCODE_NOP = 0,
+	BNXT_ULP_COND_OPCODE_COMP_FIELD = 1,
+	BNXT_ULP_COND_OPCODE_ACTION_BIT = 2,
+	BNXT_ULP_COND_OPCODE_HDR_BIT = 3,
+	BNXT_ULP_COND_OPCODE_LAST = 4
 };
 
 enum bnxt_ulp_critical_resource {
drivers/net/bnxt/tf_ulp/ulp_template_struct.h +2 -0
index 5a7a7b910..df999b18c 100644
@@ -165,6 +165,8 @@ struct bnxt_ulp_mapper_tbl_info {
 	enum bnxt_ulp_resource_func	resource_func;
 	uint32_t			resource_type; /* TF_ enum type */
 	enum bnxt_ulp_resource_sub_type	resource_sub_type;
+	enum bnxt_ulp_cond_opcode	cond_opcode;
+	uint32_t			cond_operand;
 	uint8_t		direction;
 	uint32_t	priority;
 	uint8_t		srch_b4_alloc;
Signature · 1 line
2.21.1 (Apple Git-122.3)
#197 lore raw

PATCH v4 40/51 net/bnxt: enable port MAC qcfg command for trusted VF

In reply to Ajit Khaparde

From: Venkat Duvvuru <[email protected]>

Issue HWRM_PORT_MAC_QCFG command on trusted vf to fetch the port count.

---
 drivers/net/bnxt/bnxt_hwrm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_hwrm.c +2 -2
index 2605ef039..6ade32d1b 100644
@@ -3194,14 +3194,14 @@ int bnxt_hwrm_port_mac_qcfg(struct bnxt *bp)
 
 	bp->port_svif = BNXT_SVIF_INVALID;
 
-	if (!BNXT_PF(bp))
+	if (BNXT_VF(bp) && !BNXT_VF_IS_TRUSTED(bp))
 		return 0;
 
 	HWRM_PREP(&req, HWRM_PORT_MAC_QCFG, BNXT_USE_CHIMP_MB);
 
 	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
 
-	HWRM_CHECK_RESULT();
+	HWRM_CHECK_RESULT_SILENT();
 
 	port_svif_info = rte_le_to_cpu_16(resp->port_svif_info);
 	if (port_svif_info &
Signature · 1 line
2.21.1 (Apple Git-122.3)
#198 lore raw

PATCH v4 41/51 net/bnxt: enhancements for port db

In reply to Ajit Khaparde

From: Venkat Duvvuru <[email protected]>

1. Add "enum bnxt_ulp_intf_type” as the second parameter for the port & func helper functions
2. Return vfrep related port & func information in the helper functions
3. Allocate phy_port_list dynamically based on port count
4. Introduce ulp_func_id_tbl array for book keeping func related information indexed by func_id

---
 drivers/net/bnxt/bnxt.h                  |  10 +-
 drivers/net/bnxt/bnxt_ethdev.c           |  64 ++++++++--
 drivers/net/bnxt/tf_ulp/bnxt_tf_common.h |   6 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c       |   2 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c  |   9 +-
 drivers/net/bnxt/tf_ulp/ulp_port_db.c    | 143 +++++++++++++++++------
 drivers/net/bnxt/tf_ulp/ulp_port_db.h    |  56 +++++++--
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c |  22 +++-
 8 files changed, 250 insertions(+), 62 deletions(-)
drivers/net/bnxt/bnxt.h +6 -4
index 43e5e7162..32acced60 100644
@@ -23,6 +23,7 @@
 
 #include "tf_core.h"
 #include "bnxt_ulp.h"
+#include "bnxt_tf_common.h"
 
 /* Vendor ID */
 #define PCI_VENDOR_ID_BROADCOM		0x14E4
@@ -879,10 +880,11 @@ extern const struct rte_flow_ops bnxt_ulp_rte_flow_ops;
 int32_t bnxt_ulp_init(struct bnxt *bp);
 void bnxt_ulp_deinit(struct bnxt *bp);
 
-uint16_t bnxt_get_vnic_id(uint16_t port);
-uint16_t bnxt_get_svif(uint16_t port_id, bool func_svif);
-uint16_t bnxt_get_fw_func_id(uint16_t port);
-uint16_t bnxt_get_parif(uint16_t port);
+uint16_t bnxt_get_vnic_id(uint16_t port, enum bnxt_ulp_intf_type type);
+uint16_t bnxt_get_svif(uint16_t port_id, bool func_svif,
+		       enum bnxt_ulp_intf_type type);
+uint16_t bnxt_get_fw_func_id(uint16_t port, enum bnxt_ulp_intf_type type);
+uint16_t bnxt_get_parif(uint16_t port, enum bnxt_ulp_intf_type type);
 uint16_t bnxt_get_phy_port_id(uint16_t port);
 uint16_t bnxt_get_vport(uint16_t port);
 enum bnxt_ulp_intf_type
drivers/net/bnxt/bnxt_ethdev.c +56 -8

122 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/bnxt_tf_common.h +6 -0
index f772d4919..ebb71405b 100644
@@ -6,6 +6,11 @@
 #ifndef _BNXT_TF_COMMON_H_
 #define _BNXT_TF_COMMON_H_
 
+#include <inttypes.h>
+
+#include "bnxt_ulp.h"
+#include "ulp_template_db_enum.h"
+
 #define BNXT_TF_DBG(lvl, fmt, args...)	PMD_DRV_LOG(lvl, fmt, ## args)
 
 #define BNXT_ULP_EM_FLOWS			8192
@@ -48,6 +53,7 @@ enum ulp_direction_type {
 enum bnxt_ulp_intf_type {
 	BNXT_ULP_INTF_TYPE_INVALID = 0,
 	BNXT_ULP_INTF_TYPE_PF,
+	BNXT_ULP_INTF_TYPE_TRUSTED_VF,
 	BNXT_ULP_INTF_TYPE_VF,
 	BNXT_ULP_INTF_TYPE_PF_REP,
 	BNXT_ULP_INTF_TYPE_VF_REP,
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +1 -1
index 1b52861d4..e5e7e5f43 100644
@@ -658,7 +658,7 @@ bnxt_ulp_init(struct bnxt *bp)
 	rc = ulp_dparms_init(bp, bp->ulp_ctx);
 
 	/* create the port database */
-	rc = ulp_port_db_init(bp->ulp_ctx);
+	rc = ulp_port_db_init(bp->ulp_ctx, bp->port_cnt);
 	if (rc) {
 		BNXT_TF_DBG(ERR, "Failed to create the port database\n");
 		goto jump_to_error;
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +6 -3
index 6eb2d6146..138b0b73d 100644
@@ -128,7 +128,8 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev,
 	mapper_cparms.act_prop = &params.act_prop;
 	mapper_cparms.class_tid = class_id;
 	mapper_cparms.act_tid = act_tmpl;
-	mapper_cparms.func_id = bnxt_get_fw_func_id(dev->data->port_id);
+	mapper_cparms.func_id = bnxt_get_fw_func_id(dev->data->port_id,
+						    BNXT_ULP_INTF_TYPE_INVALID);
 	mapper_cparms.dir = params.dir;
 
 	/* Call the ulp mapper to create the flow in the hardware. */
@@ -226,7 +227,8 @@ bnxt_ulp_flow_destroy(struct rte_eth_dev *dev,
 	}
 
 	flow_id = (uint32_t)(uintptr_t)flow;
-	func_id = bnxt_get_fw_func_id(dev->data->port_id);
+	func_id = bnxt_get_fw_func_id(dev->data->port_id,
+				      BNXT_ULP_INTF_TYPE_INVALID);
 
 	if (ulp_flow_db_validate_flow_func(ulp_ctx, flow_id, func_id) ==
 	    false) {
@@ -270,7 +272,8 @@ bnxt_ulp_flow_flush(struct rte_eth_dev *eth_dev,
 	if (ulp_ctx_deinit_allowed(bp)) {
 		ret = ulp_flow_db_session_flow_flush(ulp_ctx);
 	} else if (bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctx)) {
-		func_id = bnxt_get_fw_func_id(eth_dev->data->port_id);
+		func_id = bnxt_get_fw_func_id(eth_dev->data->port_id,
+					      BNXT_ULP_INTF_TYPE_INVALID);
 		ret = ulp_flow_db_function_flow_flush(ulp_ctx, func_id);
 	}
 	if (ret)
drivers/net/bnxt/tf_ulp/ulp_port_db.c +110 -33

282 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_port_db.h +47 -9

94 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +18 -4
index 8fffaecce..073b3537f 100644
@@ -166,6 +166,8 @@ ulp_rte_parser_svif_set(struct ulp_rte_parser_params *params,
 	uint16_t port_id = svif;
 	uint32_t dir = 0;
 	struct ulp_rte_hdr_field *hdr_field;
+	enum bnxt_ulp_svif_type svif_type;
+	enum bnxt_ulp_intf_type if_type;
 	uint32_t ifindex;
 	int32_t rc;
 
@@ -187,7 +189,18 @@ ulp_rte_parser_svif_set(struct ulp_rte_parser_params *params,
 				    "Invalid port id\n");
 			return BNXT_TF_RC_ERROR;
 		}
-		ulp_port_db_svif_get(params->ulp_ctx, ifindex, dir, &svif);
+
+		if (dir == ULP_DIR_INGRESS) {
+			svif_type = BNXT_ULP_PHY_PORT_SVIF;
+		} else {
+			if_type = bnxt_get_interface_type(port_id);
+			if (if_type == BNXT_ULP_INTF_TYPE_VF_REP)
+				svif_type = BNXT_ULP_VF_FUNC_SVIF;
+			else
+				svif_type = BNXT_ULP_DRV_FUNC_SVIF;
+		}
+		ulp_port_db_svif_get(params->ulp_ctx, ifindex, svif_type,
+				     &svif);
 		svif = rte_cpu_to_be_16(svif);
 	}
 	hdr_field = &params->hdr_field[BNXT_ULP_PROTO_HDR_FIELD_SVIF_IDX];
@@ -1256,7 +1269,7 @@ ulp_rte_pf_act_handler(const struct rte_flow_action *action_item __rte_unused,
 
 	/* copy the PF of the current device into VNIC Property */
 	svif = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_INCOMING_IF);
-	svif = bnxt_get_vnic_id(svif);
+	svif = bnxt_get_vnic_id(svif, BNXT_ULP_INTF_TYPE_INVALID);
 	svif = rte_cpu_to_be_32(svif);
 	memcpy(&params->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
 	       &svif, BNXT_ULP_ACT_PROP_SZ_VNIC);
@@ -1280,7 +1293,8 @@ ulp_rte_vf_act_handler(const struct rte_flow_action *action_item,
 			return BNXT_TF_RC_PARSE_ERR;
 		}
 		/* TBD: Update the computed VNIC using VF conversion */
-		pid = bnxt_get_vnic_id(vf_action->id);
+		pid = bnxt_get_vnic_id(vf_action->id,
+				       BNXT_ULP_INTF_TYPE_INVALID);
 		pid = rte_cpu_to_be_32(pid);
 		memcpy(&param->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
 		       &pid, BNXT_ULP_ACT_PROP_SZ_VNIC);
@@ -1307,7 +1321,7 @@ ulp_rte_port_id_act_handler(const struct rte_flow_action *act_item,
 			return BNXT_TF_RC_PARSE_ERR;
 		}
 		/* TBD: Update the computed VNIC using port conversion */
-		pid = bnxt_get_vnic_id(port_id->id);
+		pid = bnxt_get_vnic_id(port_id->id, BNXT_ULP_INTF_TYPE_INVALID);
 		pid = rte_cpu_to_be_32(pid);
 		memcpy(&param->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
 		       &pid, BNXT_ULP_ACT_PROP_SZ_VNIC);
Signature · 1 line
2.21.1 (Apple Git-122.3)
#199 lore raw

PATCH v4 42/51 net/bnxt: manage VF to VFR conduit

In reply to Ajit Khaparde

From: Venkat Duvvuru <[email protected]>

When VF-VFR conduits are created, a mark is added to the mark database. mark_flag indicates whether the mark is valid and has VFR information (VFR_ID bit in mark_flag). Rx path was checking for this VFR_ID bit. However, while adding the mark to the mark database, VFR_ID bit is not set in mark_flag.

---
 drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c +5 -0
index b3527eccb..b2c8c349c 100644
@@ -18,6 +18,8 @@
 						BNXT_ULP_MARK_VALID)
 #define ULP_MARK_DB_ENTRY_IS_INVALID(mark_info) (!((mark_info)->flags &\
 						   BNXT_ULP_MARK_VALID))
+#define ULP_MARK_DB_ENTRY_SET_VFR_ID(mark_info) ((mark_info)->flags |=\
+						 BNXT_ULP_MARK_VFR_ID)
 #define ULP_MARK_DB_ENTRY_IS_VFR_ID(mark_info) ((mark_info)->flags &\
 						BNXT_ULP_MARK_VFR_ID)
 #define ULP_MARK_DB_ENTRY_IS_GLOBAL_HW_FID(mark_info) ((mark_info)->flags &\
@@ -263,6 +265,9 @@ ulp_mark_db_mark_add(struct bnxt_ulp_context *ctxt,
 		BNXT_TF_DBG(DEBUG, "Set LFID[0x%0x] = 0x%0x\n", fid, mark);
 		mtbl->lfid_tbl[fid].mark_id = mark;
 		ULP_MARK_DB_ENTRY_SET_VALID(&mtbl->lfid_tbl[fid]);
+
+		if (mark_flag & BNXT_ULP_MARK_VFR_ID)
+			ULP_MARK_DB_ENTRY_SET_VFR_ID(&mtbl->lfid_tbl[fid]);
 	}
 
 	return 0;
Signature · 1 line
2.21.1 (Apple Git-122.3)
#200 lore raw

PATCH v4 43/51 net/bnxt: parse reps along with other dev-args

In reply to Ajit Khaparde

From: Somnath Kotur <[email protected]>

Representor dev-args need to be parsed during pci probe as they determine subsequent probe of VF representor ports as well.

---
 drivers/net/bnxt/bnxt_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/bnxt/bnxt_ethdev.c +2 -0
index 332644d77..0b38c84e3 100644
@@ -98,8 +98,10 @@ static const struct rte_pci_id bnxt_pci_id_map[] = {
 #define BNXT_DEVARG_TRUFLOW	"host-based-truflow"
 #define BNXT_DEVARG_FLOW_XSTAT	"flow-xstat"
 #define BNXT_DEVARG_MAX_NUM_KFLOWS  "max-num-kflows"
+#define BNXT_DEVARG_REPRESENTOR	"representor"
 
 static const char *const bnxt_dev_args[] = {
+	BNXT_DEVARG_REPRESENTOR,
 	BNXT_DEVARG_TRUFLOW,
 	BNXT_DEVARG_FLOW_XSTAT,
 	BNXT_DEVARG_MAX_NUM_KFLOWS,
Signature · 1 line
2.21.1 (Apple Git-122.3)
#201 lore raw

PATCH v4 44/51 net/bnxt: fill mapper parameters with default rules

In reply to Ajit Khaparde

From: Venkat Duvvuru <[email protected]>

Default rules are needed for the packets to be punted between the following entities in the non-offloaded path
1. Device PORT to DPDK App
2. DPDK App to Device PORT
3. VF Representor to VF
4. VF to VF Representor

This patch fills all the relevant information in the computed fields & the act_prop fields for the flow mapper to create the necessary tables in the hardware to enable the default rules.

---
 drivers/net/bnxt/bnxt_ethdev.c                |   6 +-
 drivers/net/bnxt/meson.build                  |   1 +
 drivers/net/bnxt/tf_ulp/Makefile              |   1 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h            |  24 ++
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c       |  30 +-
 drivers/net/bnxt/tf_ulp/ulp_def_rules.c       | 385 ++++++++++++++++++
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          |  10 +-
 drivers/net/bnxt/tf_ulp/ulp_mapper.h          |   3 +-
 .../net/bnxt/tf_ulp/ulp_template_db_enum.h    |   5 +
 9 files changed, 444 insertions(+), 21 deletions(-)
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_def_rules.c
drivers/net/bnxt/bnxt_ethdev.c +3 -3
index 0b38c84e3..de8e11a6e 100644
@@ -1275,9 +1275,6 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
 	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 
-	if (BNXT_TRUFLOW_EN(bp))
-		bnxt_ulp_deinit(bp);
-
 	eth_dev->data->dev_started = 0;
 	/* Prevent crashes when queues are still in use */
 	eth_dev->rx_pkt_burst = &bnxt_dummy_recv_pkts;
@@ -1333,6 +1330,9 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
 	rte_eal_alarm_cancel(bnxt_dev_recover, (void *)bp);
 	bnxt_cancel_fc_thread(bp);
 
+	if (BNXT_TRUFLOW_EN(bp))
+		bnxt_ulp_deinit(bp);
+
 	if (eth_dev->data->dev_started)
 		bnxt_dev_stop_op(eth_dev);
 
drivers/net/bnxt/meson.build +1 -0
index 8f6ed419e..2939857ca 100644
@@ -61,6 +61,7 @@ sources = files('bnxt_cpr.c',
 	'tf_ulp/ulp_rte_parser.c',
 	'tf_ulp/bnxt_ulp_flow.c',
 	'tf_ulp/ulp_port_db.c',
+	'tf_ulp/ulp_def_rules.c',
 
 	'rte_pmd_bnxt.c')
 
drivers/net/bnxt/tf_ulp/Makefile +1 -0
index 57341f876..3f1b43bae 100644
@@ -16,3 +16,4 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/bnxt_ulp.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_mark_mgr.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_flow_db.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_port_db.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_def_rules.c
drivers/net/bnxt/tf_ulp/bnxt_ulp.h +24 -0
index eecc09cea..3563f63fa 100644
@@ -12,6 +12,8 @@
 
 #include "rte_ethdev.h"
 
+#include "ulp_template_db_enum.h"
+
 struct bnxt_ulp_data {
 	uint32_t			tbl_scope_id;
 	struct bnxt_ulp_mark_tbl	*mark_tbl;
@@ -49,6 +51,12 @@ struct rte_tf_flow {
 	uint32_t	flow_id;
 };
 
+struct ulp_tlv_param {
+	enum bnxt_ulp_df_param_type type;
+	uint32_t length;
+	uint8_t value[16];
+};
+
 /*
  * Allow the deletion of context only for the bnxt device that
  * created the session
@@ -127,4 +135,20 @@ bnxt_ulp_cntxt_ptr2_port_db_set(struct bnxt_ulp_context	*ulp_ctx,
 struct bnxt_ulp_port_db *
 bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context	*ulp_ctx);
 
+/* Function to create default flows. */
+int32_t
+ulp_default_flow_create(struct rte_eth_dev *eth_dev,
+			struct ulp_tlv_param *param_list,
+			uint32_t ulp_class_tid,
+			uint32_t *flow_id);
+
+/* Function to destroy default flows. */
+int32_t
+ulp_default_flow_destroy(struct rte_eth_dev *eth_dev,
+			 uint32_t flow_id);
+
+int
+bnxt_ulp_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
+		      struct rte_flow_error *error);
+
 #endif /* _BNXT_ULP_H_ */
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +18 -12
index 138b0b73d..7ef306e58 100644
@@ -207,7 +207,7 @@ bnxt_ulp_flow_validate(struct rte_eth_dev *dev,
 }
 
 /* Function to destroy the rte flow. */
-static int
+int
 bnxt_ulp_flow_destroy(struct rte_eth_dev *dev,
 		      struct rte_flow *flow,
 		      struct rte_flow_error *error)
@@ -220,9 +220,10 @@ bnxt_ulp_flow_destroy(struct rte_eth_dev *dev,
 	ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(dev);
 	if (!ulp_ctx) {
 		BNXT_TF_DBG(ERR, "ULP context is not initialized\n");
-		rte_flow_error_set(error, EINVAL,
-				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-				   "Failed to destroy flow.");
+		if (error)
+			rte_flow_error_set(error, EINVAL,
+					   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+					   "Failed to destroy flow.");
 		return -EINVAL;
 	}
 
@@ -233,17 +234,22 @@ bnxt_ulp_flow_destroy(struct rte_eth_dev *dev,
 	if (ulp_flow_db_validate_flow_func(ulp_ctx, flow_id, func_id) ==
 	    false) {
 		BNXT_TF_DBG(ERR, "Incorrect device params\n");
-		rte_flow_error_set(error, EINVAL,
-				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-				   "Failed to destroy flow.");
+		if (error)
+			rte_flow_error_set(error, EINVAL,
+					   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+					   "Failed to destroy flow.");
 		return -EINVAL;
 	}
 
-	ret = ulp_mapper_flow_destroy(ulp_ctx, flow_id);
-	if (ret)
-		rte_flow_error_set(error, -ret,
-				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-				   "Failed to destroy flow.");
+	ret = ulp_mapper_flow_destroy(ulp_ctx, flow_id,
+				      BNXT_ULP_REGULAR_FLOW_TABLE);
+	if (ret) {
+		BNXT_TF_DBG(ERR, "Failed to destroy flow.\n");
+		if (error)
+			rte_flow_error_set(error, -ret,
+					   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+					   "Failed to destroy flow.");
+	}
 
 	return ret;
 }
drivers/net/bnxt/tf_ulp/ulp_def_rules.c new file +385 -0

385 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_mapper.c +5 -5
index d0931d411..e39398a1b 100644
@@ -2274,16 +2274,15 @@ ulp_mapper_glb_resource_info_deinit(struct bnxt_ulp_context *ulp_ctx,
 }
 
 int32_t
-ulp_mapper_flow_destroy(struct bnxt_ulp_context	*ulp_ctx, uint32_t fid)
+ulp_mapper_flow_destroy(struct bnxt_ulp_context	*ulp_ctx, uint32_t fid,
+			enum bnxt_ulp_flow_db_tables flow_tbl_type)
 {
 	if (!ulp_ctx) {
 		BNXT_TF_DBG(ERR, "Invalid parms, unable to free flow\n");
 		return -EINVAL;
 	}
 
-	return ulp_mapper_resources_free(ulp_ctx,
-					 fid,
-					 BNXT_ULP_REGULAR_FLOW_TABLE);
+	return ulp_mapper_resources_free(ulp_ctx, fid, flow_tbl_type);
 }
 
 /* Function to handle the default global templates that are allocated during
@@ -2486,7 +2485,8 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 
 flow_error:
 	/* Free all resources that were allocated during flow creation */
-	trc = ulp_mapper_flow_destroy(ulp_ctx, parms.fid);
+	trc = ulp_mapper_flow_destroy(ulp_ctx, parms.fid,
+				      BNXT_ULP_REGULAR_FLOW_TABLE);
 	if (trc)
 		BNXT_TF_DBG(ERR, "Failed to free all resources rc=%d\n", trc);
 
drivers/net/bnxt/tf_ulp/ulp_mapper.h +2 -1
index 19134830a..b35065449 100644
@@ -109,7 +109,8 @@ ulp_mapper_flow_create(struct bnxt_ulp_context	*ulp_ctx,
 
 /* Function that frees all resources associated with the flow. */
 int32_t
-ulp_mapper_flow_destroy(struct bnxt_ulp_context	*ulp_ctx, uint32_t fid);
+ulp_mapper_flow_destroy(struct bnxt_ulp_context	*ulp_ctx, uint32_t fid,
+			enum bnxt_ulp_flow_db_tables flow_tbl_type);
 
 /*
  * Function that frees all resources and can be called on default or regular
drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h +5 -0
index 27628a510..2346797db 100644
@@ -145,6 +145,11 @@ enum bnxt_ulp_device_id {
 	BNXT_ULP_DEVICE_ID_LAST = 4
 };
 
+enum bnxt_ulp_df_param_type {
+	BNXT_ULP_DF_PARAM_TYPE_DEV_PORT_ID = 0,
+	BNXT_ULP_DF_PARAM_TYPE_LAST = 1
+};
+
 enum bnxt_ulp_direction {
 	BNXT_ULP_DIRECTION_INGRESS = 0,
 	BNXT_ULP_DIRECTION_EGRESS = 1,
Signature · 1 line
2.21.1 (Apple Git-122.3)
#202 lore raw

PATCH v4 45/51 net/bnxt: add VF-rep and stat templates

In reply to Ajit Khaparde

From: Kishore Padmanabha <[email protected]>

The support for VF representor and counters is added to the ulp templates.

---
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          |   21 +-
 drivers/net/bnxt/tf_ulp/ulp_mapper.h          |    2 +-
 drivers/net/bnxt/tf_ulp/ulp_template_db_act.c |  424 +-
 .../net/bnxt/tf_ulp/ulp_template_db_class.c   | 5198 +++++++++++++----
 .../net/bnxt/tf_ulp/ulp_template_db_enum.h    |  409 +-
 .../net/bnxt/tf_ulp/ulp_template_db_field.h   |  463 +-
 drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c |   87 +-
 7 files changed, 4948 insertions(+), 1656 deletions(-)
drivers/net/bnxt/tf_ulp/ulp_mapper.c +2 -19
index e39398a1b..3f175fb51 100644
@@ -22,7 +22,7 @@ ulp_mapper_glb_resource_info_list_get(uint32_t *num_entries)
 {
 	if (!num_entries)
 		return NULL;
-	*num_entries = BNXT_ULP_GLB_RESOURCE_INFO_TBL_MAX_SZ;
+	*num_entries = BNXT_ULP_GLB_RESOURCE_TBL_MAX_SZ;
 	return ulp_glb_resource_tbl;
 }
 
@@ -119,11 +119,6 @@ ulp_mapper_resource_ident_allocate(struct bnxt_ulp_context *ulp_ctx,
 		tf_free_identifier(tfp, &fparms);
 		return rc;
 	}
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-	BNXT_TF_DBG(DEBUG, "Allocated Glb Res Ident [%s][%d][%d] = 0x%04x\n",
-		    (iparms.dir == TF_DIR_RX) ? "RX" : "TX",
-		    glb_res->glb_regfile_index, iparms.ident_type, iparms.id);
-#endif
 	return rc;
 }
 
@@ -182,11 +177,6 @@ ulp_mapper_resource_index_tbl_alloc(struct bnxt_ulp_context *ulp_ctx,
 		tf_free_tbl_entry(tfp, &free_parms);
 		return rc;
 	}
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-	BNXT_TF_DBG(DEBUG, "Allocated Glb Res Index [%s][%d][%d] = 0x%04x\n",
-		    (aparms.dir == TF_DIR_RX) ? "RX" : "TX",
-		    glb_res->glb_regfile_index, aparms.type, aparms.idx);
-#endif
 	return rc;
 }
 
@@ -1441,9 +1431,6 @@ ulp_mapper_em_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 			return rc;
 		}
 	}
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-	ulp_mapper_result_dump("EEM Result", tbl, &data);
-#endif
 
 	/* do the transpose for the internal EM keys */
 	if (tbl->resource_func == BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE)
@@ -1594,10 +1581,6 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	/* if encap bit swap is enabled perform the bit swap */
 	if (parms->device_params->encap_byte_swap && encap_flds) {
 		ulp_blob_perform_encap_swap(&data);
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-		BNXT_TF_DBG(INFO, "Dump after encap swap\n");
-		ulp_mapper_blob_dump(&data);
-#endif
 	}
 
 	/*
@@ -2255,7 +2238,7 @@ ulp_mapper_glb_resource_info_deinit(struct bnxt_ulp_context *ulp_ctx,
 
 	/* Iterate the global resources and process each one */
 	for (dir = TF_DIR_RX; dir < TF_DIR_MAX; dir++) {
-		for (idx = 0; idx < BNXT_ULP_GLB_RESOURCE_INFO_TBL_MAX_SZ;
+		for (idx = 0; idx < BNXT_ULP_GLB_RESOURCE_TBL_MAX_SZ;
 		      idx++) {
 			ent = &mapper_data->glb_res_tbl[dir][idx];
 			if (ent->resource_func ==
drivers/net/bnxt/tf_ulp/ulp_mapper.h +1 -1
index b35065449..f6d55449b 100644
@@ -46,7 +46,7 @@ struct bnxt_ulp_mapper_glb_resource_entry {
 
 struct bnxt_ulp_mapper_data {
 	struct bnxt_ulp_mapper_glb_resource_entry
-		glb_res_tbl[TF_DIR_MAX][BNXT_ULP_GLB_RESOURCE_INFO_TBL_MAX_SZ];
+		glb_res_tbl[TF_DIR_MAX][BNXT_ULP_GLB_RESOURCE_TBL_MAX_SZ];
 	struct bnxt_ulp_mapper_cache_entry
 		*cache_tbl[BNXT_ULP_CACHE_TBL_MAX_SZ];
 };
drivers/net/bnxt/tf_ulp/ulp_template_db_act.c +391 -33

541 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_template_db_class.c +4027 -1171

2,394 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h +218 -191

409 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_template_db_field.h +259 -204

463 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c +50 -37

87 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.21.1 (Apple Git-122.3)

Part of the diff is not shown here. View the raw message.

#203 lore raw

PATCH v4 46/51 net/bnxt: create default flow rules for the VF-rep

In reply to Ajit Khaparde

From: Somnath Kotur <[email protected]>

Invoked 3 new APIs for the default flow create/destroy and to get the action ptr for a default flow.
Changed ulp_intf_update() to accept rte_eth_dev as input and invoke the same from the VF rep start function.
ULP Mark Manager will indicate if the cfa_code returned in the Rx completion descriptor was for one of the default flow rules created for the VF representor conduit. The mark_id returned in such a case would be the VF rep's DPDK Port id, which can be used to get the corresponding rte_eth_dev struct in bnxt_vf_recv

---
 drivers/net/bnxt/bnxt.h      |   4 +-
 drivers/net/bnxt/bnxt_reps.c | 134 ++++++++++++++++++++++++-----------
 drivers/net/bnxt/bnxt_reps.h |   3 +-
 drivers/net/bnxt/bnxt_rxr.c  |  25 +++----
 drivers/net/bnxt/bnxt_txq.h  |   1 +
 5 files changed, 111 insertions(+), 56 deletions(-)
drivers/net/bnxt/bnxt.h +3 -1
index 32acced60..f16bf3319 100644
@@ -806,8 +806,10 @@ struct bnxt_vf_representor {
 	uint16_t		fw_fid;
 	uint16_t		dflt_vnic_id;
 	uint16_t		svif;
-	uint16_t		tx_cfa_action;
+	uint32_t		vfr_tx_cfa_action;
 	uint16_t		rx_cfa_code;
+	uint32_t		rep2vf_flow_id;
+	uint32_t		vf2rep_flow_id;
 	/* Private data store of associated PF/Trusted VF */
 	struct rte_eth_dev	*parent_dev;
 	uint8_t			mac_addr[RTE_ETHER_ADDR_LEN];
drivers/net/bnxt/bnxt_reps.c +93 -41

222 lines not on this page · raw message

drivers/net/bnxt/bnxt_reps.h +1 -2
index 5c2e0a0b9..418b95afc 100644
@@ -13,8 +13,7 @@
 #define BNXT_VF_IDX_INVALID             0xffff
 
 uint16_t
-bnxt_vfr_recv(struct bnxt *bp, uint16_t cfa_code, uint16_t queue_id,
-	      struct rte_mbuf *mbuf);
+bnxt_vfr_recv(uint16_t port_id, uint16_t queue_id, struct rte_mbuf *mbuf);
 int bnxt_vf_representor_init(struct rte_eth_dev *eth_dev, void *params);
 int bnxt_vf_representor_uninit(struct rte_eth_dev *eth_dev);
 int bnxt_vf_rep_dev_info_get_op(struct rte_eth_dev *eth_dev,
drivers/net/bnxt/bnxt_rxr.c +13 -12
index 37b534fc2..64058879e 100644
@@ -403,9 +403,9 @@ bnxt_get_rx_ts_thor(struct bnxt *bp, uint32_t rx_ts_cmpl)
 }
 #endif
 
-static void
+static uint32_t
 bnxt_ulp_set_mark_in_mbuf(struct bnxt *bp, struct rx_pkt_cmpl_hi *rxcmp1,
-			  struct rte_mbuf *mbuf)
+			  struct rte_mbuf *mbuf, uint32_t *vfr_flag)
 {
 	uint32_t cfa_code;
 	uint32_t meta_fmt;
@@ -415,8 +415,6 @@ bnxt_ulp_set_mark_in_mbuf(struct bnxt *bp, struct rx_pkt_cmpl_hi *rxcmp1,
 	uint32_t flags2;
 	uint32_t gfid_support = 0;
 	int rc;
-	uint32_t vfr_flag;
-
 
 	if (BNXT_GFID_ENABLED(bp))
 		gfid_support = 1;
@@ -485,19 +483,21 @@ bnxt_ulp_set_mark_in_mbuf(struct bnxt *bp, struct rx_pkt_cmpl_hi *rxcmp1,
 	}
 
 	rc = ulp_mark_db_mark_get(bp->ulp_ctx, gfid,
-				  cfa_code, &vfr_flag, &mark_id);
+				  cfa_code, vfr_flag, &mark_id);
 	if (!rc) {
 		/* Got the mark, write it to the mbuf and return */
 		mbuf->hash.fdir.hi = mark_id;
 		mbuf->udata64 = (cfa_code & 0xffffffffull) << 32;
 		mbuf->hash.fdir.id = rxcmp1->cfa_code;
 		mbuf->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
-		return;
+		return mark_id;
 	}
 
 skip_mark:
 	mbuf->hash.fdir.hi = 0;
 	mbuf->hash.fdir.id = 0;
+
+	return 0;
 }
 
 void bnxt_set_mark_in_mbuf(struct bnxt *bp,
@@ -553,7 +553,7 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
 	int rc = 0;
 	uint8_t agg_buf = 0;
 	uint16_t cmp_type;
-	uint32_t flags2_f = 0;
+	uint32_t flags2_f = 0, vfr_flag = 0, mark_id = 0;
 	uint16_t flags_type;
 	struct bnxt *bp = rxq->bp;
 
@@ -632,7 +632,8 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
 	}
 
 	if (BNXT_TRUFLOW_EN(bp))
-		bnxt_ulp_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf);
+		mark_id = bnxt_ulp_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf,
+						    &vfr_flag);
 	else
 		bnxt_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf);
 
@@ -736,10 +737,10 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
 rx:
 	*rx_pkt = mbuf;
 
-	if ((BNXT_VF_IS_TRUSTED(rxq->bp) || BNXT_PF(rxq->bp)) &&
-	    rxq->bp->cfa_code_map && rxcmp1->cfa_code) {
-		if (!bnxt_vfr_recv(rxq->bp, rxcmp1->cfa_code, rxq->queue_id,
-				   mbuf)) {
+	if (BNXT_TRUFLOW_EN(bp) &&
+	    (BNXT_VF_IS_TRUSTED(bp) || BNXT_PF(bp)) &&
+	    vfr_flag) {
+		if (!bnxt_vfr_recv(mark_id, rxq->queue_id, mbuf)) {
 			/* Now return an error so that nb_rx_pkts is not
 			 * incremented.
 			 * This packet was meant to be given to the representor.
drivers/net/bnxt/bnxt_txq.h +1 -0
index 69ff89aab..a1ab3f39a 100644
@@ -30,6 +30,7 @@ struct bnxt_tx_queue {
 	int			index;
 	int			tx_wake_thresh;
 	uint32_t                tx_cfa_action;
+	uint32_t		vfr_tx_cfa_action;
 	struct bnxt_tx_ring_info	*tx_ring;
 
 	unsigned int		cp_nr_rings;
Signature · 1 line
2.21.1 (Apple Git-122.3)
#204 lore raw

PATCH v4 47/51 net/bnxt: add port default rules for ingress and egress

In reply to Ajit Khaparde

From: Venkat Duvvuru <[email protected]>

ingress & egress port default rules are needed to send the packet from port_to_dpdk & dpdk_to_port respectively.

---
 drivers/net/bnxt/bnxt_ethdev.c     | 76 +++++++++++++++++++++++++++++-
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h |  3 ++
 2 files changed, 78 insertions(+), 1 deletion(-)
drivers/net/bnxt/bnxt_ethdev.c +75 -1
index de8e11a6e..2a19c5040 100644
@@ -29,6 +29,7 @@
 #include "hsi_struct_def_dpdk.h"
 #include "bnxt_nvm_defs.h"
 #include "bnxt_tf_common.h"
+#include "ulp_flow_db.h"
 
 #define DRV_MODULE_NAME		"bnxt"
 static const char bnxt_version[] =
@@ -1162,6 +1163,73 @@ static int bnxt_handle_if_change_status(struct bnxt *bp)
 	return rc;
 }
 
+static int32_t
+bnxt_create_port_app_df_rule(struct bnxt *bp, uint8_t flow_type,
+			     uint32_t *flow_id)
+{
+	uint16_t port_id = bp->eth_dev->data->port_id;
+	struct ulp_tlv_param param_list[] = {
+		{
+			.type = BNXT_ULP_DF_PARAM_TYPE_DEV_PORT_ID,
+			.length = 2,
+			.value = {(port_id >> 8) & 0xff, port_id & 0xff}
+		},
+		{
+			.type = BNXT_ULP_DF_PARAM_TYPE_LAST,
+			.length = 0,
+			.value = {0}
+		}
+	};
+
+	return ulp_default_flow_create(bp->eth_dev, param_list, flow_type,
+				       flow_id);
+}
+
+static int32_t
+bnxt_create_df_rules(struct bnxt *bp)
+{
+	struct bnxt_ulp_data *cfg_data;
+	int rc;
+
+	cfg_data = bp->ulp_ctx->cfg_data;
+	rc = bnxt_create_port_app_df_rule(bp, BNXT_ULP_DF_TPL_PORT_TO_VS,
+					  &cfg_data->port_to_app_flow_id);
+	if (rc) {
+		PMD_DRV_LOG(ERR,
+			    "Failed to create port to app default rule\n");
+		return rc;
+	}
+
+	BNXT_TF_DBG(DEBUG, "***** created port to app default rule ******\n");
+	rc = bnxt_create_port_app_df_rule(bp, BNXT_ULP_DF_TPL_VS_TO_PORT,
+					  &cfg_data->app_to_port_flow_id);
+	if (!rc) {
+		rc = ulp_default_flow_db_cfa_action_get(bp->ulp_ctx,
+							cfg_data->app_to_port_flow_id,
+							&cfg_data->tx_cfa_action);
+		if (rc)
+			goto err;
+
+		BNXT_TF_DBG(DEBUG,
+			    "***** created app to port default rule *****\n");
+		return 0;
+	}
+
+err:
+	BNXT_TF_DBG(DEBUG, "Failed to create app to port default rule\n");
+	return rc;
+}
+
+static void
+bnxt_destroy_df_rules(struct bnxt *bp)
+{
+	struct bnxt_ulp_data *cfg_data;
+
+	cfg_data = bp->ulp_ctx->cfg_data;
+	ulp_default_flow_destroy(bp->eth_dev, cfg_data->port_to_app_flow_id);
+	ulp_default_flow_destroy(bp->eth_dev, cfg_data->app_to_port_flow_id);
+}
+
 static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = eth_dev->data->dev_private;
@@ -1330,8 +1398,11 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
 	rte_eal_alarm_cancel(bnxt_dev_recover, (void *)bp);
 	bnxt_cancel_fc_thread(bp);
 
-	if (BNXT_TRUFLOW_EN(bp))
+	if (BNXT_TRUFLOW_EN(bp)) {
+		if (bp->rep_info != NULL)
+			bnxt_destroy_df_rules(bp);
 		bnxt_ulp_deinit(bp);
+	}
 
 	if (eth_dev->data->dev_started)
 		bnxt_dev_stop_op(eth_dev);
@@ -1581,6 +1652,9 @@ static int bnxt_promiscuous_disable_op(struct rte_eth_dev *eth_dev)
 	if (rc != 0)
 		vnic->flags = old_flags;
 
+	if (BNXT_TRUFLOW_EN(bp) && bp->rep_info != NULL)
+		bnxt_create_df_rules(bp);
+
 	return rc;
 }
 
drivers/net/bnxt/tf_ulp/bnxt_ulp.h +3 -0
index 3563f63fa..4843da562 100644
@@ -22,6 +22,9 @@ struct bnxt_ulp_data {
 	struct bnxt_ulp_flow_db		*flow_db;
 	void				*mapper_data;
 	struct bnxt_ulp_port_db		*port_db;
+	uint32_t			port_to_app_flow_id;
+	uint32_t			app_to_port_flow_id;
+	uint32_t			tx_cfa_action;
 };
 
 struct bnxt_ulp_context {
Signature · 1 line
2.21.1 (Apple Git-122.3)
#205 lore raw

PATCH v4 48/51 net/bnxt: fill cfa action in the Tx descriptor

In reply to Ajit Khaparde

From: Venkat Duvvuru <[email protected]>

Currently, only vfrep transmit requires cfa_action to be filled in the tx buffer descriptor. However with truflow, dpdk(non vfrep) to port also requires cfa_action to be filled in the tx buffer descriptor.

This patch uses the correct cfa_action pointer while transmitting the packet. Based on whether the packet is transmitted on non-vfrep or vfrep, tx_cfa_action or vfr_tx_cfa_action inside txq will be filled in the tx buffer descriptor.

---
 drivers/net/bnxt/bnxt_txr.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/net/bnxt/bnxt_txr.c +15 -3
index d7e193d38..f5884268e 100644
@@ -131,7 +131,9 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
 				PKT_TX_VLAN_PKT | PKT_TX_OUTER_IP_CKSUM |
 				PKT_TX_TUNNEL_GRE | PKT_TX_TUNNEL_VXLAN |
 				PKT_TX_TUNNEL_GENEVE | PKT_TX_IEEE1588_TMST |
-				PKT_TX_QINQ_PKT) || txq->tx_cfa_action)
+				PKT_TX_QINQ_PKT) ||
+	     txq->bp->ulp_ctx->cfg_data->tx_cfa_action ||
+	     txq->vfr_tx_cfa_action)
 		long_bd = true;
 
 	nr_bds = long_bd + tx_pkt->nb_segs;
@@ -184,7 +186,15 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
 	if (long_bd) {
 		txbd->flags_type |= TX_BD_LONG_TYPE_TX_BD_LONG;
 		vlan_tag_flags = 0;
-		cfa_action = txq->tx_cfa_action;
+
+		if (BNXT_TRUFLOW_EN(txq->bp)) {
+			if (txq->vfr_tx_cfa_action)
+				cfa_action = txq->vfr_tx_cfa_action;
+			else
+				cfa_action =
+				      txq->bp->ulp_ctx->cfg_data->tx_cfa_action;
+		}
+
 		/* HW can accelerate only outer vlan in QinQ mode */
 		if (tx_buf->mbuf->ol_flags & PKT_TX_QINQ_PKT) {
 			vlan_tag_flags = TX_BD_LONG_CFA_META_KEY_VLAN_TAG |
@@ -212,7 +222,9 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
 					&txr->tx_desc_ring[txr->tx_prod];
 		txbd1->lflags = 0;
 		txbd1->cfa_meta = vlan_tag_flags;
-		txbd1->cfa_action = cfa_action;
+
+		if (BNXT_TRUFLOW_EN(txq->bp))
+			txbd1->cfa_action = cfa_action;
 
 		if (tx_pkt->ol_flags & PKT_TX_TCP_SEG) {
 			uint16_t hdr_size;
Signature · 1 line
2.21.1 (Apple Git-122.3)
#206 lore raw

PATCH v4 49/51 net/bnxt: add ULP Flow counter Manager

In reply to Ajit Khaparde

From: Somnath Kotur <[email protected]>

The Flow counter manager allocates memory to hold the software view of the counters where the on-chip counter data will be accumulated along with another memory block that will be shadowing the on-chip counter data i.e where the raw counter data will be DMAed into from the chip.
It also keeps track of the first HW counter ID as that will be needed to retrieve the counter data in bulk using a TF API. It issues this cmd in an rte_alarm thread that keeps running every second.

---
 drivers/net/bnxt/meson.build          |   1 +
 drivers/net/bnxt/tf_ulp/Makefile      |   1 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c    |  35 ++
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h    |   8 +
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c  | 465 ++++++++++++++++++++++++++
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h  | 148 ++++++++
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c |  27 ++
 7 files changed, 685 insertions(+)
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
drivers/net/bnxt/meson.build +1 -0
index 2939857ca..5fb0ed380 100644
@@ -46,6 +46,7 @@ sources = files('bnxt_cpr.c',
 	'tf_core/ll.c',
 	'tf_core/tf_global_cfg.c',
 	'tf_core/tf_em_host.c',
+	'tf_ulp/ulp_fc_mgr.c',
 
 	'hcapi/hcapi_cfa_p4.c',
 
drivers/net/bnxt/tf_ulp/Makefile +1 -0
index 3f1b43bae..abb68150d 100644
@@ -17,3 +17,4 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_mark_mgr.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_flow_db.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_port_db.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_def_rules.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_fc_mgr.c
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +35 -0
index e5e7e5f43..c05861150 100644
@@ -18,6 +18,7 @@
 #include "ulp_template_db_enum.h"
 #include "ulp_template_struct.h"
 #include "ulp_mark_mgr.h"
+#include "ulp_fc_mgr.h"
 #include "ulp_flow_db.h"
 #include "ulp_mapper.h"
 #include "ulp_port_db.h"
@@ -705,6 +706,12 @@ bnxt_ulp_init(struct bnxt *bp)
 		goto jump_to_error;
 	}
 
+	rc = ulp_fc_mgr_init(bp->ulp_ctx);
+	if (rc) {
+		BNXT_TF_DBG(ERR, "Failed to initialize ulp flow counter mgr\n");
+		goto jump_to_error;
+	}
+
 	return rc;
 
 jump_to_error:
@@ -752,6 +759,9 @@ bnxt_ulp_deinit(struct bnxt *bp)
 	/* cleanup the ulp mapper */
 	ulp_mapper_deinit(bp->ulp_ctx);
 
+	/* Delete the Flow Counter Manager */
+	ulp_fc_mgr_deinit(bp->ulp_ctx);
+
 	/* Delete the Port database */
 	ulp_port_db_deinit(bp->ulp_ctx);
 
@@ -963,3 +973,28 @@ bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context	*ulp_ctx)
 
 	return ulp_ctx->cfg_data->port_db;
 }
+
+/* Function to set the flow counter info into the context */
+int32_t
+bnxt_ulp_cntxt_ptr2_fc_info_set(struct bnxt_ulp_context *ulp_ctx,
+				struct bnxt_ulp_fc_info *ulp_fc_info)
+{
+	if (!ulp_ctx || !ulp_ctx->cfg_data) {
+		BNXT_TF_DBG(ERR, "Invalid ulp context data\n");
+		return -EINVAL;
+	}
+
+	ulp_ctx->cfg_data->fc_info = ulp_fc_info;
+
+	return 0;
+}
+
+/* Function to retrieve the flow counter info from the context. */
+struct bnxt_ulp_fc_info *
+bnxt_ulp_cntxt_ptr2_fc_info_get(struct bnxt_ulp_context *ulp_ctx)
+{
+	if (!ulp_ctx || !ulp_ctx->cfg_data)
+		return NULL;
+
+	return ulp_ctx->cfg_data->fc_info;
+}
drivers/net/bnxt/tf_ulp/bnxt_ulp.h +8 -0
index 4843da562..a13328426 100644
@@ -22,6 +22,7 @@ struct bnxt_ulp_data {
 	struct bnxt_ulp_flow_db		*flow_db;
 	void				*mapper_data;
 	struct bnxt_ulp_port_db		*port_db;
+	struct bnxt_ulp_fc_info		*fc_info;
 	uint32_t			port_to_app_flow_id;
 	uint32_t			app_to_port_flow_id;
 	uint32_t			tx_cfa_action;
@@ -154,4 +155,11 @@ int
 bnxt_ulp_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
 		      struct rte_flow_error *error);
 
+int32_t
+bnxt_ulp_cntxt_ptr2_fc_info_set(struct bnxt_ulp_context *ulp_ctx,
+				struct bnxt_ulp_fc_info *ulp_fc_info);
+
+struct bnxt_ulp_fc_info *
+bnxt_ulp_cntxt_ptr2_fc_info_get(struct bnxt_ulp_context *ulp_ctx);
+
 #endif /* _BNXT_ULP_H_ */
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c new file +465 -0

465 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h new file +148 -0

148 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_flow_db.c +27 -0
index 7696de2a5..a3cfe54bf 100644
@@ -10,6 +10,7 @@
 #include "ulp_utils.h"
 #include "ulp_template_struct.h"
 #include "ulp_mapper.h"
+#include "ulp_fc_mgr.h"
 
 #define ULP_FLOW_DB_RES_DIR_BIT		31
 #define ULP_FLOW_DB_RES_DIR_MASK	0x80000000
@@ -484,6 +485,21 @@ int32_t	ulp_flow_db_resource_add(struct bnxt_ulp_context	*ulp_ctxt,
 		ulp_flow_db_res_params_to_info(fid_resource, params);
 	}
 
+	if (params->resource_type == TF_TBL_TYPE_ACT_STATS_64 &&
+	    params->resource_sub_type ==
+	    BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_INT_COUNT) {
+		/* Store the first HW counter ID for this table */
+		if (!ulp_fc_mgr_start_idx_isset(ulp_ctxt, params->direction))
+			ulp_fc_mgr_start_idx_set(ulp_ctxt, params->direction,
+						 params->resource_hndl);
+
+		ulp_fc_mgr_cntr_set(ulp_ctxt, params->direction,
+				    params->resource_hndl);
+
+		if (!ulp_fc_mgr_thread_isstarted(ulp_ctxt))
+			ulp_fc_mgr_thread_start(ulp_ctxt);
+	}
+
 	/* all good, return success */
 	return 0;
 }
@@ -574,6 +590,17 @@ int32_t	ulp_flow_db_resource_del(struct bnxt_ulp_context	*ulp_ctxt,
 					nxt_idx);
 	}
 
+	/* Now that the HW Flow counter resource is deleted, reset it's
+	 * corresponding slot in the SW accumulation table in the Flow Counter
+	 * manager
+	 */
+	if (params->resource_type == TF_TBL_TYPE_ACT_STATS_64 &&
+	    params->resource_sub_type ==
+	    BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_INT_COUNT) {
+		ulp_fc_mgr_cntr_reset(ulp_ctxt, params->direction,
+				      params->resource_hndl);
+	}
+
 	/* all good, return success */
 	return 0;
 }
Signature · 1 line
2.21.1 (Apple Git-122.3)
#207 lore raw

PATCH v4 50/51 net/bnxt: add support for count action in flow query

In reply to Ajit Khaparde

From: Somnath Kotur <[email protected]>

Use the flow counter manager to fetch the accumulated stats for a flow.

---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c |  45 +++++++-
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c    | 141 +++++++++++++++++++++++-
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h    |  17 ++-
 3 files changed, 196 insertions(+), 7 deletions(-)
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +44 -1
index 7ef306e58..36a014184 100644
@@ -9,6 +9,7 @@
 #include "ulp_matcher.h"
 #include "ulp_flow_db.h"
 #include "ulp_mapper.h"
+#include "ulp_fc_mgr.h"
 #include <rte_malloc.h>
 
 static int32_t
@@ -289,11 +290,53 @@ bnxt_ulp_flow_flush(struct rte_eth_dev *eth_dev,
 	return ret;
 }
 
+/* Function to query the rte flows. */
+static int32_t
+bnxt_ulp_flow_query(struct rte_eth_dev *eth_dev,
+		    struct rte_flow *flow,
+		    const struct rte_flow_action *action,
+		    void *data,
+		    struct rte_flow_error *error)
+{
+	int rc = 0;
+	struct bnxt_ulp_context *ulp_ctx;
+	struct rte_flow_query_count *count;
+	uint32_t flow_id;
+
+	ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(eth_dev);
+	if (!ulp_ctx) {
+		BNXT_TF_DBG(ERR, "ULP context is not initialized\n");
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+				   "Failed to query flow.");
+		return -EINVAL;
+	}
+
+	flow_id = (uint32_t)(uintptr_t)flow;
+
+	switch (action->type) {
+	case RTE_FLOW_ACTION_TYPE_COUNT:
+		count = data;
+		rc = ulp_fc_mgr_query_count_get(ulp_ctx, flow_id, count);
+		if (rc) {
+			rte_flow_error_set(error, EINVAL,
+					   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+					   "Failed to query flow.");
+		}
+		break;
+	default:
+		rte_flow_error_set(error, -rc, RTE_FLOW_ERROR_TYPE_ACTION_NUM,
+				   NULL, "Unsupported action item");
+	}
+
+	return rc;
+}
+
 const struct rte_flow_ops bnxt_ulp_rte_flow_ops = {
 	.validate = bnxt_ulp_flow_validate,
 	.create = bnxt_ulp_flow_create,
 	.destroy = bnxt_ulp_flow_destroy,
 	.flush = bnxt_ulp_flow_flush,
-	.query = NULL,
+	.query = bnxt_ulp_flow_query,
 	.isolate = NULL
 };
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c +136 -5

200 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h +16 -1
index faa77dd75..207267049 100644
@@ -23,6 +23,7 @@ struct sw_acc_counter {
 	uint64_t pkt_count;
 	uint64_t byte_count;
 	bool	valid;
+	uint32_t hw_cntr_id;
 };
 
 struct hw_fc_mem_info {
@@ -142,7 +143,21 @@ bool ulp_fc_mgr_start_idx_isset(struct bnxt_ulp_context *ctxt, enum tf_dir dir);
  * ctxt [in] The ulp context for the flow counter manager
  *
  */
-
 bool ulp_fc_mgr_thread_isstarted(struct bnxt_ulp_context *ctxt);
 
+/*
+ * Fill the rte_flow_query_count 'data' argument passed
+ * in the rte_flow_query() with the values obtained and
+ * accumulated locally.
+ *
+ * ctxt [in] The ulp context for the flow counter manager
+ *
+ * flow_id [in] The HW flow ID
+ *
+ * count [out] The rte_flow_query_count 'data' that is set
+ *
+ */
+int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ulp_ctx,
+			       uint32_t flow_id,
+			       struct rte_flow_query_count *count);
 #endif /* _ULP_FC_MGR_H_ */
Signature · 1 line
2.21.1 (Apple Git-122.3)
#208 lore raw

PATCH v4 51/51 doc: update release notes

In reply to Ajit Khaparde

Update release notes with enhancements in Broadcom PMD.

---
 doc/guides/rel_notes/release_20_08.rst | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_20_08.rst +10 -1
index 5cbc4ce14..9bcea29ba 100644
@@ -91,6 +91,16 @@ New Features
 
   * Added support for DCF datapath configuration.
 
+* **Updated Broadcom bnxt driver.**
+
+  Updated the Broadcom bnxt driver with new features and improvements, including:
+
+  * Added support for VF representors.
+  * Added support for multiple devices.
+  * Added support for new resource manager API.
+  * Added support for VXLAN encap/decap.
+  * Added support for rte_flow_query for COUNT action.
+
 * **Added support for BPF_ABS/BPF_IND load instructions.**
 
   Added support for two BPF non-generic instructions:
@@ -107,7 +117,6 @@ New Features
   * Dump ``rte_flow`` memory consumption.
   * Measure packet per second forwarding.
 
-
 Removed Items
 -------------
 
Signature · 1 line
2.21.1 (Apple Git-122.3)
#209 lore raw

v5 cover net/bnxt: add features for host-based flow management

In reply to Ferruh Yigit

v1->v2:
- update commit message
- rebase patches against latest changes in the tree
- fix signed-off-by tags
- update release notes

v2->v3:
- fix compilation issues

v3->v4:
- rebase against latest dpdk-next-net

v4->v5:
- fix uninitlalized variable in patch [29/51]
- rebase against latest dpdk-next-net

Ajit Khaparde (1):
doc: update release notes

Jay Ding (5):
net/bnxt: implement support for TCAM access
net/bnxt: support two level priority for TCAMs
net/bnxt: add external action alloc and free
net/bnxt: implement IF tables set and get
net/bnxt: add global config set and get APIs

Kishore Padmanabha (8):
net/bnxt: integrate with the latest tf core changes net/bnxt: add support for if table processing net/bnxt: disable Tx vector mode if truflow is enabled net/bnxt: add index opcode and operand to mapper table net/bnxt: add support for global resource templates net/bnxt: add support for internal exact match entries net/bnxt: add support for conditional execution of mapper tables net/bnxt: add VF-rep and stat templates

Lance Richardson (1):
net/bnxt: initialize parent PF information

Michael Wildt (7):
net/bnxt: add multi device support
net/bnxt: update multi device design support
net/bnxt: multiple device implementation
net/bnxt: update identifier with remap support
net/bnxt: update RM with residual checker
net/bnxt: update table get to use new design
net/bnxt: add TF register and unregister

Mike Baucom (1):
net/bnxt: add support for internal encap records

Peter Spreadborough (7):
net/bnxt: add support for exact match
net/bnxt: modify EM insert and delete to use HWRM direct net/bnxt: add HCAPI interface support
net/bnxt: support EM and TCAM lookup with table scope net/bnxt: update RM to support HCAPI only net/bnxt: remove table scope from session net/bnxt: add support for EEM System memory

Randy Schacher (2):
net/bnxt: add core changes for EM and EEM lookups net/bnxt: align CFA resources with RM

Shahaji Bhosle (2):
net/bnxt: support bulk table get and mirror
net/bnxt: support two-level priority for TCAMs

Somnath Kotur (7):
net/bnxt: add basic infrastructure for VF reps net/bnxt: add support for VF-reps data path net/bnxt: get IDs for VF-Rep endpoint net/bnxt: parse reps along with other dev-args net/bnxt: create default flow rules for the VF-rep net/bnxt: add ULP Flow counter Manager net/bnxt: add support for count action in flow query

Venkat Duvvuru (10):
net/bnxt: modify port db dev interface net/bnxt: get port and function info
net/bnxt: add support for hwrm port phy qcaps net/bnxt: modify port db to handle more info net/bnxt: enable port MAC qcfg command for trusted VF net/bnxt: enhancements for port db
net/bnxt: manage VF to VFR conduit
net/bnxt: fill mapper parameters with default rules net/bnxt: add port default rules for ingress and egress net/bnxt: fill cfa action in the Tx descriptor

 config/common_base                            |    1 +
 doc/guides/rel_notes/release_20_08.rst        |   11 +-
 drivers/net/bnxt/Makefile                     |    8 +-
 drivers/net/bnxt/bnxt.h                       |  121 +-
 drivers/net/bnxt/bnxt_ethdev.c                |  519 +-
 drivers/net/bnxt/bnxt_hwrm.c                  |  122 +-
 drivers/net/bnxt/bnxt_hwrm.h                  |    7 +
 drivers/net/bnxt/bnxt_reps.c                  |  773 +++
 drivers/net/bnxt/bnxt_reps.h                  |   45 +
 drivers/net/bnxt/bnxt_rxr.c                   |   39 +-
 drivers/net/bnxt/bnxt_rxr.h                   |    1 +
 drivers/net/bnxt/bnxt_txq.h                   |    2 +
 drivers/net/bnxt/bnxt_txr.c                   |   18 +-
 drivers/net/bnxt/hcapi/Makefile               |   10 +
 drivers/net/bnxt/hcapi/cfa_p40_hw.h           |  781 +++
 drivers/net/bnxt/hcapi/cfa_p40_tbl.h          |  303 +
 drivers/net/bnxt/hcapi/hcapi_cfa.h            |  276 +
 drivers/net/bnxt/hcapi/hcapi_cfa_defs.h       |  672 +++
 drivers/net/bnxt/hcapi/hcapi_cfa_p4.c         |  399 ++
 drivers/net/bnxt/hcapi/hcapi_cfa_p4.h         |  467 ++
 drivers/net/bnxt/hsi_struct_def_dpdk.h        | 3091 ++++++++--
 drivers/net/bnxt/meson.build                  |   21 +-
 drivers/net/bnxt/tf_core/Makefile             |   29 +-
 drivers/net/bnxt/tf_core/bitalloc.c           |  107 +
 drivers/net/bnxt/tf_core/bitalloc.h           |    5 +
 drivers/net/bnxt/tf_core/cfa_resource_types.h |  293 +
 drivers/net/bnxt/tf_core/hwrm_tf.h            |  995 +---
 drivers/net/bnxt/tf_core/ll.c                 |   52 +
 drivers/net/bnxt/tf_core/ll.h                 |   46 +
 drivers/net/bnxt/tf_core/lookup3.h            |    1 -
 drivers/net/bnxt/tf_core/stack.c              |    8 +
 drivers/net/bnxt/tf_core/stack.h              |   10 +
 drivers/net/bnxt/tf_core/tf_common.h          |   43 +
 drivers/net/bnxt/tf_core/tf_core.c            | 1495 +++--
 drivers/net/bnxt/tf_core/tf_core.h            |  874 ++-
 drivers/net/bnxt/tf_core/tf_device.c          |  271 +
 drivers/net/bnxt/tf_core/tf_device.h          |  650 ++
 drivers/net/bnxt/tf_core/tf_device_p4.c       |  147 +
 drivers/net/bnxt/tf_core/tf_device_p4.h       |  104 +
 drivers/net/bnxt/tf_core/tf_em.c              |  515 --
 drivers/net/bnxt/tf_core/tf_em.h              |  492 +-
 drivers/net/bnxt/tf_core/tf_em_common.c       | 1048 ++++
 drivers/net/bnxt/tf_core/tf_em_common.h       |  134 +
 drivers/net/bnxt/tf_core/tf_em_host.c         |  531 ++
 drivers/net/bnxt/tf_core/tf_em_internal.c     |  352 ++
 drivers/net/bnxt/tf_core/tf_em_system.c       |  533 ++
 drivers/net/bnxt/tf_core/tf_ext_flow_handle.h |   12 +
 drivers/net/bnxt/tf_core/tf_global_cfg.c      |  199 +
 drivers/net/bnxt/tf_core/tf_global_cfg.h      |  170 +
 drivers/net/bnxt/tf_core/tf_identifier.c      |  186 +
 drivers/net/bnxt/tf_core/tf_identifier.h      |  147 +
 drivers/net/bnxt/tf_core/tf_if_tbl.c          |  178 +
 drivers/net/bnxt/tf_core/tf_if_tbl.h          |  236 +
 drivers/net/bnxt/tf_core/tf_msg.c             | 1681 +++---
 drivers/net/bnxt/tf_core/tf_msg.h             |  409 +-
 drivers/net/bnxt/tf_core/tf_resources.h       |  531 --
 drivers/net/bnxt/tf_core/tf_rm.c              | 3840 +++---------
 drivers/net/bnxt/tf_core/tf_rm.h              |  554 +-
 drivers/net/bnxt/tf_core/tf_session.c         |  776 +++
 drivers/net/bnxt/tf_core/tf_session.h         |  565 +-
 drivers/net/bnxt/tf_core/tf_shadow_tbl.c      |   63 +
 drivers/net/bnxt/tf_core/tf_shadow_tbl.h      |  240 +
 drivers/net/bnxt/tf_core/tf_shadow_tcam.c     |   63 +
 drivers/net/bnxt/tf_core/tf_shadow_tcam.h     |  239 +
 drivers/net/bnxt/tf_core/tf_tbl.c             | 1930 +-----
 drivers/net/bnxt/tf_core/tf_tbl.h             |  469 +-
 drivers/net/bnxt/tf_core/tf_tcam.c            |  430 ++
 drivers/net/bnxt/tf_core/tf_tcam.h            |  360 ++
 drivers/net/bnxt/tf_core/tf_util.c            |  176 +
 drivers/net/bnxt/tf_core/tf_util.h            |   98 +
 drivers/net/bnxt/tf_core/tfp.c                |   33 +-
 drivers/net/bnxt/tf_core/tfp.h                |  153 +-
 drivers/net/bnxt/tf_ulp/Makefile              |    2 +
 drivers/net/bnxt/tf_ulp/bnxt_tf_common.h      |   16 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |  129 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h            |   35 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c       |   84 +-
 drivers/net/bnxt/tf_ulp/ulp_def_rules.c       |  385 ++
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c          |  596 ++
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h          |  163 +
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c         |   42 +-
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          |  481 +-
 drivers/net/bnxt/tf_ulp/ulp_mapper.h          |    6 +-
 drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c        |   10 +
 drivers/net/bnxt/tf_ulp/ulp_port_db.c         |  235 +-
 drivers/net/bnxt/tf_ulp/ulp_port_db.h         |  122 +-
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c      |   30 +-
 drivers/net/bnxt/tf_ulp/ulp_template_db_act.c |  433 +-
 .../net/bnxt/tf_ulp/ulp_template_db_class.c   | 5217 +++++++++++++----
 .../net/bnxt/tf_ulp/ulp_template_db_enum.h    |  537 +-
 .../net/bnxt/tf_ulp/ulp_template_db_field.h   |  463 +-
 drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c |   85 +-
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |   23 +-
 drivers/net/bnxt/tf_ulp/ulp_utils.c           |    2 +-
 94 files changed, 28009 insertions(+), 11247 deletions(-)
 create mode 100644 drivers/net/bnxt/bnxt_reps.c
 create mode 100644 drivers/net/bnxt/bnxt_reps.h
 create mode 100644 drivers/net/bnxt/hcapi/Makefile
 create mode 100644 drivers/net/bnxt/hcapi/cfa_p40_hw.h
 create mode 100644 drivers/net/bnxt/hcapi/cfa_p40_tbl.h
 create mode 100644 drivers/net/bnxt/hcapi/hcapi_cfa.h
 create mode 100644 drivers/net/bnxt/hcapi/hcapi_cfa_defs.h
 create mode 100644 drivers/net/bnxt/hcapi/hcapi_cfa_p4.c
 create mode 100644 drivers/net/bnxt/hcapi/hcapi_cfa_p4.h
 create mode 100644 drivers/net/bnxt/tf_core/cfa_resource_types.h
 create mode 100644 drivers/net/bnxt/tf_core/ll.c
 create mode 100644 drivers/net/bnxt/tf_core/ll.h
 create mode 100644 drivers/net/bnxt/tf_core/tf_common.h
 create mode 100644 drivers/net/bnxt/tf_core/tf_device.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_device.h
 create mode 100644 drivers/net/bnxt/tf_core/tf_device_p4.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_device_p4.h
 delete mode 100644 drivers/net/bnxt/tf_core/tf_em.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_em_common.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_em_common.h
 create mode 100644 drivers/net/bnxt/tf_core/tf_em_host.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_em_internal.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_em_system.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_global_cfg.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_global_cfg.h
 create mode 100644 drivers/net/bnxt/tf_core/tf_identifier.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_identifier.h
 create mode 100644 drivers/net/bnxt/tf_core/tf_if_tbl.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_if_tbl.h
 create mode 100644 drivers/net/bnxt/tf_core/tf_session.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_shadow_tbl.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_shadow_tbl.h
 create mode 100644 drivers/net/bnxt/tf_core/tf_shadow_tcam.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_shadow_tcam.h
 create mode 100644 drivers/net/bnxt/tf_core/tf_tcam.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_tcam.h
 create mode 100644 drivers/net/bnxt/tf_core/tf_util.c
 create mode 100644 drivers/net/bnxt/tf_core/tf_util.h
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_def_rules.c
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
Signature · 1 line
2.21.1 (Apple Git-122.3)
#210 lore raw

PATCH v5 1/51 net/bnxt: add basic infrastructure for VF reps

From: Somnath Kotur <[email protected]>

Defines data structures and code to init/uninit
VF representors during pci_probe and pci_remove respectively.
Most of the dev_ops for the VF representor are just stubs for now and will be will be filled out in next patch.

To create a representor using testpmd:
testpmd -c 0xff -wB:D.F,representor=1 -- -i
testpmd -c 0xff -w05:02.0,representor=[1] -- -i

To create a representor using ovs-dpdk:
1. Firt add the trusted VF port to a bridge
ovs-vsctl add-port ovsbr0 vf_rep1 -- set Interface vf_rep1 type=dpdk options:dpdk-devargs=0000:06:02.0
2. Add the representor port to the bridge
ovs-vsctl add-port ovsbr0 vf_rep1 -- set Interface vf_rep1 type=dpdk options:dpdk-devargs=0000:06:02.0,representor=1

---
 drivers/net/bnxt/Makefile      |   2 +
 drivers/net/bnxt/bnxt.h        |  64 +++++++-
 drivers/net/bnxt/bnxt_ethdev.c | 225 ++++++++++++++++++++------
 drivers/net/bnxt/bnxt_reps.c   | 287 +++++++++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_reps.h   |  35 ++++
 drivers/net/bnxt/meson.build   |   1 +
 6 files changed, 566 insertions(+), 48 deletions(-)
 create mode 100644 drivers/net/bnxt/bnxt_reps.c
 create mode 100644 drivers/net/bnxt/bnxt_reps.h
drivers/net/bnxt/Makefile +2 -0
index a375299c3..365627499 100644
@@ -14,6 +14,7 @@ LIB = librte_pmd_bnxt.a
 EXPORT_MAP := rte_pmd_bnxt_version.map
 
 CFLAGS += -O3
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += $(WERROR_FLAGS)
 LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
 LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
@@ -38,6 +39,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txr.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_irq.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_util.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_reps.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += rte_pmd_bnxt.c
 ifeq ($(CONFIG_RTE_ARCH_X86), y)
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxtx_vec_sse.c
drivers/net/bnxt/bnxt.h +63 -1

107 lines not on this page · raw message

drivers/net/bnxt/bnxt_ethdev.c +178 -47

304 lines not on this page · raw message

drivers/net/bnxt/bnxt_reps.c new file +287 -0

287 lines not on this page · raw message

drivers/net/bnxt/bnxt_reps.h new file +35 -0
new file mode 100644
index 000000000..6048faf08
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2014-2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _BNXT_REPS_H_
+#define _BNXT_REPS_H_
+
+#include <rte_malloc.h>
+#include <rte_ethdev.h>
+
+int bnxt_vf_representor_init(struct rte_eth_dev *eth_dev, void *params);
+int bnxt_vf_representor_uninit(struct rte_eth_dev *eth_dev);
+int bnxt_vf_rep_dev_info_get_op(struct rte_eth_dev *eth_dev,
+				struct rte_eth_dev_info *dev_info);
+int bnxt_vf_rep_dev_configure_op(struct rte_eth_dev *eth_dev);
+
+int bnxt_vf_rep_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_compl);
+int bnxt_vf_rep_dev_start_op(struct rte_eth_dev *eth_dev);
+int bnxt_vf_rep_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
+				  __rte_unused uint16_t queue_idx,
+				  __rte_unused uint16_t nb_desc,
+				  __rte_unused unsigned int socket_id,
+				  __rte_unused const struct rte_eth_rxconf *
+				  rx_conf,
+				  __rte_unused struct rte_mempool *mp);
+int bnxt_vf_rep_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
+				  __rte_unused uint16_t queue_idx,
+				  __rte_unused uint16_t nb_desc,
+				  __rte_unused unsigned int socket_id,
+				  __rte_unused const struct rte_eth_txconf *
+				  tx_conf);
+void bnxt_vf_rep_dev_stop_op(struct rte_eth_dev *eth_dev);
+void bnxt_vf_rep_dev_close_op(struct rte_eth_dev *eth_dev);
+#endif /* _BNXT_REPS_H_ */
drivers/net/bnxt/meson.build +1 -0
index 4306c6039..5c7859cb5 100644
@@ -21,6 +21,7 @@ sources = files('bnxt_cpr.c',
 	'bnxt_txr.c',
 	'bnxt_util.c',
 	'bnxt_vnic.c',
+	'bnxt_reps.c',
 
 	'tf_core/tf_core.c',
 	'tf_core/bitalloc.c',
Signature · 1 line
2.21.1 (Apple Git-122.3)
#211 lore raw

Re: [dpdk-dev] [PATCH v5 01/51] net/bnxt: add basic infrastructure for VF reps

Quoted 24 lines · Ajit Khaparde

From: Somnath Kotur <[email protected]>

Defines data structures and code to init/uninit
VF representors during pci_probe and pci_remove respectively.
Most of the dev_ops for the VF representor are just stubs for now and will be will be filled out in next patch.

To create a representor using testpmd:
testpmd -c 0xff -wB:D.F,representor=1 -- -i
testpmd -c 0xff -w05:02.0,representor=[1] -- -i

To create a representor using ovs-dpdk:
1. Firt add the trusted VF port to a bridge
ovs-vsctl add-port ovsbr0 vf_rep1 -- set Interface vf_rep1 type=dpdk options:dpdk-devargs=0000:06:02.0
2. Add the representor port to the bridge
ovs-vsctl add-port ovsbr0 vf_rep1 -- set Interface vf_rep1 type=dpdk options:dpdk-devargs=0000:06:02.0,representor=1

<...>

Quoted 5 lines

static int bnxt_pci_remove(struct rte_pci_device *pci_dev) {

drivers/net/bnxt/bnxt_ethdev.c +0 -3
-	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
-		return rte_eth_dev_pci_generic_remove(pci_dev,
-				bnxt_dev_uninit);

drivers/net/bnxt/bnxt_ethdev.c bnxt_dev_uninit(struct rte_eth_dev *eth_dev) · line 5821

Quoted 10 lines
drivers/net/bnxt/bnxt_ethdev.c +9 -1
-	else
+	struct rte_eth_dev *eth_dev;
+
+	eth_dev = rte_eth_dev_allocated(pci_dev->device.name);
+	if (!eth_dev)
+		return ENODEV; /* Invoked typically only by OVS-DPDK, by the
+				* time it comes here the eth_dev is already
+				* deleted by rte_eth_dev_close(), so returning
+				* +ve value will atleast help in proper cleanup
+				*/

Why returning a positive error value? It hides the error since the caller of the function does a "< 0" check.
Better to be more explicit and return '0' if an error is not intendent in this case.

#212 lore raw

Re: [dpdk-dev] [PATCH v5 01/51] net/bnxt: add basic infrastructure for VF reps

Quoted 45 lines · Ferruh Yigit
Quoted 24 lines · Ajit Khaparde

From: Somnath Kotur <[email protected]>

Defines data structures and code to init/uninit
VF representors during pci_probe and pci_remove respectively.
Most of the dev_ops for the VF representor are just stubs for now and will be will be filled out in next patch.

To create a representor using testpmd:
testpmd -c 0xff -wB:D.F,representor=1 -- -i
testpmd -c 0xff -w05:02.0,representor=[1] -- -i

To create a representor using ovs-dpdk:
1. Firt add the trusted VF port to a bridge
ovs-vsctl add-port ovsbr0 vf_rep1 -- set Interface vf_rep1 type=dpdk options:dpdk-devargs=0000:06:02.0
2. Add the representor port to the bridge
ovs-vsctl add-port ovsbr0 vf_rep1 -- set Interface vf_rep1 type=dpdk options:dpdk-devargs=0000:06:02.0,representor=1

<...>

Quoted 5 lines

static int bnxt_pci_remove(struct rte_pci_device *pci_dev) {

drivers/net/bnxt/bnxt_ethdev.c +0 -3
-     if (rte_eal_process_type() == RTE_PROC_PRIMARY)
-             return rte_eth_dev_pci_generic_remove(pci_dev,
-                             bnxt_dev_uninit);

drivers/net/bnxt/bnxt_ethdev.c bnxt_dev_uninit(struct rte_eth_dev *eth_dev) · line 5821

Quoted 10 lines
drivers/net/bnxt/bnxt_ethdev.c +9 -1
-     else
+     struct rte_eth_dev *eth_dev;
+
+     eth_dev = rte_eth_dev_allocated(pci_dev->device.name);
+     if (!eth_dev)
+             return ENODEV; /* Invoked typically only by OVS-DPDK, by the
+                             * time it comes here the eth_dev is already
+                             * deleted by rte_eth_dev_close(), so returning
+                             * +ve value will atleast help in proper cleanup
+                             */
Quoted 4 lines

Why returning a positive error value? It hides the error since the caller of the function does a "< 0" check.
Better to be more explicit and return '0' if an error is not intendent in this case.

Sure, makes sense Ferruh

#213 lore raw

Re: [dpdk-dev] [PATCH v5 01/51] net/bnxt: add basic infrastructure for VF reps

Quoted 51 lines · Somnath Kotur
Quoted 29 lines · Ferruh Yigit
Quoted 24 lines · Ajit Khaparde

From: Somnath Kotur <[email protected]>

Defines data structures and code to init/uninit
VF representors during pci_probe and pci_remove respectively.
Most of the dev_ops for the VF representor are just stubs for now and will be will be filled out in next patch.

To create a representor using testpmd:
testpmd -c 0xff -wB:D.F,representor=1 -- -i
testpmd -c 0xff -w05:02.0,representor=[1] -- -i

To create a representor using ovs-dpdk:
1. Firt add the trusted VF port to a bridge
ovs-vsctl add-port ovsbr0 vf_rep1 -- set Interface vf_rep1 type=dpdk options:dpdk-devargs=0000:06:02.0
2. Add the representor port to the bridge
ovs-vsctl add-port ovsbr0 vf_rep1 -- set Interface vf_rep1 type=dpdk options:dpdk-devargs=0000:06:02.0,representor=1

<...>

Quoted 11 lines

drivers/net/bnxt/bnxt_ethdev.c bnxt_dev_uninit(struct rte_eth_dev *eth_dev)

Quoted 11 lines

static int bnxt_pci_remove(struct rte_pci_device *pci_dev) {

drivers/net/bnxt/bnxt_ethdev.c +5 -4
-     if (rte_eal_process_type() == RTE_PROC_PRIMARY)
-             return rte_eth_dev_pci_generic_remove(pci_dev,
-                             bnxt_dev_uninit);
-     else
+     struct rte_eth_dev *eth_dev;
+
+     eth_dev = rte_eth_dev_allocated(pci_dev->device.name);
+     if (!eth_dev)
+             return ENODEV; /* Invoked typically only by OVS-DPDK, by

the

Quoted 1 line
Quoted 1 line

+ * time it comes here the eth_dev is

already

Quoted 1 line
Quoted 1 line

+ * deleted by rte_eth_dev_close(), so

returning

Quoted 1 line
Quoted 1 line

+ * +ve value will atleast help in proper

cleanup

Quoted 2 lines
Quoted 1 line

+ */

Quoted 8 lines
Quoted 1 line

Why returning a positive error value? It hides the error since the

caller of the

Quoted 2 lines

function does a "< 0" check.
Better to be more explicit and return '0' if an error is not intendent

in this case.

Quoted 1 line

Sure, makes sense Ferruh

Ferruh,
Do you want Som to send a fresh patchset?
Or send a fix just this with a new patch?

#214 lore raw

Re: [dpdk-dev] [PATCH v5 01/51] net/bnxt: add basic infrastructure for VF reps

Quoted 63 lines · Ajit Khaparde

On Mon, Jul 6, 2020 at 7:05 AM Somnath Kotur <[email protected] <mailto:[email protected]>> wrote:

On Mon, Jul 6, 2020 at 3:37 PM Ferruh Yigit <[email protected] <mailto:[email protected]>> wrote:
>
> On 7/3/2020 10:01 PM, Ajit Khaparde wrote:
> > From: Somnath Kotur <[email protected] <mailto:[email protected]>>
> >
> > Defines data structures and code to init/uninit
> > VF representors during pci_probe and pci_remove
> > respectively.
> > Most of the dev_ops for the VF representor are just
> > stubs for now and will be will be filled out in next patch.
> >
> > To create a representor using testpmd:
> > testpmd -c 0xff -wB:D.F,representor=1 -- -i
> > testpmd -c 0xff -w05:02.0,representor=[1] -- -i
> >
> > To create a representor using ovs-dpdk:
> > 1. Firt add the trusted VF port to a bridge
> > ovs-vsctl add-port ovsbr0 vf_rep1 -- set Interface vf_rep1 type=dpdk > > options:dpdk-devargs=0000:06:02.0
> > 2. Add the representor port to the bridge
> > ovs-vsctl add-port ovsbr0 vf_rep1 -- set Interface vf_rep1 type=dpdk > > options:dpdk-devargs=0000:06:02.0,representor=1
> >
> > Signed-off-by: Somnath Kotur <[email protected] <mailto:[email protected]>>
> > Signed-off-by: Venkat Duvvuru <[email protected] <mailto:[email protected]>>
> > Reviewed-by: Kalesh AP <[email protected] <mailto:[email protected]>>
> > Reviewed-by: Ajit Khaparde <[email protected] <mailto:[email protected]>>
>
> <...>
>
> >  static int bnxt_pci_remove(struct rte_pci_device *pci_dev)
> >  {
> > -     if (rte_eal_process_type() == RTE_PROC_PRIMARY)
> > -             return rte_eth_dev_pci_generic_remove(pci_dev,
> > -                             bnxt_dev_uninit);
> > -     else
> > +     struct rte_eth_dev *eth_dev;
> > +
> > +     eth_dev = rte_eth_dev_allocated(pci_dev->device.name
<http://device.name>);
> > +     if (!eth_dev)
> > +             return ENODEV; /* Invoked typically only by OVS-DPDK, by the > > +                             * time it comes here the eth_dev is already > > +                             * deleted by rte_eth_dev_close(), so returning > > +                             * +ve value will atleast help in proper cleanup
> > +                             */
>
> Why returning a positive error value? It hides the error since the caller of the
> function does a "< 0" check.
> Better to be more explicit and return '0' if an error is not intendent in this case.
>

Quoted 5 lines

Sure, makes sense Ferruh

Ferruh,
Do you want Som to send a fresh patchset?
Or send a fix just this with a new patch?

I will update this as "return 0;" while merging, no new patchset required.

#215 lore raw

PATCH v5 2/51 net/bnxt: add support for VF-reps data path

In reply to Ajit Khaparde

From: Somnath Kotur <[email protected]>

Added code to support Tx/Rx from a VF representor port.
The VF-reps use the RX/TX rings of the Trusted VF/PF.
For each VF-rep, the Trusted VF/PF driver issues a VFR_ALLOC FW cmd that returns "cfa_code" and "cfa_action" values.
The FW sets up the filter tables in such a way that VF traffic by default (in absence of other rules) gets punted to the parent function i.e. either the Trusted VF or the PF.
The cfa_code value in the RX-compl informs the driver of the source VF. For traffic being transmitted from the VF-rep, the TX BD is tagged with a cfa_action value that informs the HW to punt it to the corresponding VF.

---
 drivers/net/bnxt/bnxt.h        |  30 ++-
 drivers/net/bnxt/bnxt_ethdev.c | 150 ++++++++---
 drivers/net/bnxt/bnxt_reps.c   | 476 +++++++++++++++++++++++++++++++--
 drivers/net/bnxt/bnxt_reps.h   |  11 +
 drivers/net/bnxt/bnxt_rxr.c    |  22 +-
 drivers/net/bnxt/bnxt_rxr.h    |   1 +
 drivers/net/bnxt/bnxt_txq.h    |   1 +
 drivers/net/bnxt/bnxt_txr.c    |   4 +-
 8 files changed, 616 insertions(+), 79 deletions(-)
drivers/net/bnxt/bnxt.h +24 -6
index 9b7b87cee..443d9fee4 100644
@@ -495,6 +495,7 @@ struct bnxt_mark_info {
 
 struct bnxt_rep_info {
 	struct rte_eth_dev	*vfr_eth_dev;
+	pthread_mutex_t		vfr_lock;
 };
 
 /* address space location of register */
@@ -755,7 +756,8 @@ struct bnxt {
 	uint16_t		fw_reset_max_msecs;
 	uint16_t		switch_domain_id;
 	uint16_t		num_reps;
-	struct bnxt_rep_info	rep_info[BNXT_MAX_VF_REPS];
+	struct bnxt_rep_info	*rep_info;
+	uint16_t                *cfa_code_map;
 	/* Struct to hold adapter error recovery related info */
 	struct bnxt_error_recovery_info *recovery_info;
 #define BNXT_MARK_TABLE_SZ	(sizeof(struct bnxt_mark_info)  * 64 * 1024)
@@ -780,12 +782,28 @@ struct bnxt {
  * Structure to store private data for each VF representor instance
  */
 struct bnxt_vf_representor {
-	uint16_t switch_domain_id;
-	uint16_t vf_id;
+	uint16_t		switch_domain_id;
+	uint16_t		vf_id;
+	uint16_t		tx_cfa_action;
+	uint16_t		rx_cfa_code;
 	/* Private data store of associated PF/Trusted VF */
-	struct bnxt	*parent_priv;
-	uint8_t		mac_addr[RTE_ETHER_ADDR_LEN];
-	uint8_t		dflt_mac_addr[RTE_ETHER_ADDR_LEN];
+	struct rte_eth_dev	*parent_dev;
+	uint8_t			mac_addr[RTE_ETHER_ADDR_LEN];
+	uint8_t			dflt_mac_addr[RTE_ETHER_ADDR_LEN];
+	struct bnxt_rx_queue	**rx_queues;
+	unsigned int		rx_nr_rings;
+	unsigned int		tx_nr_rings;
+	uint64_t                tx_pkts[BNXT_MAX_VF_REP_RINGS];
+	uint64_t                tx_bytes[BNXT_MAX_VF_REP_RINGS];
+	uint64_t                rx_pkts[BNXT_MAX_VF_REP_RINGS];
+	uint64_t                rx_bytes[BNXT_MAX_VF_REP_RINGS];
+	uint64_t                rx_drop_pkts[BNXT_MAX_VF_REP_RINGS];
+	uint64_t                rx_drop_bytes[BNXT_MAX_VF_REP_RINGS];
+};
+
+struct bnxt_vf_rep_tx_queue {
+	struct bnxt_tx_queue *txq;
+	struct bnxt_vf_representor *bp;
 };
 
 int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu);
drivers/net/bnxt/bnxt_ethdev.c +108 -42

209 lines not on this page · raw message

drivers/net/bnxt/bnxt_reps.c +449 -27

565 lines not on this page · raw message

drivers/net/bnxt/bnxt_reps.h +11 -0
index 6048faf08..5c2e0a0b9 100644
@@ -9,6 +9,12 @@
 #include <rte_malloc.h>
 #include <rte_ethdev.h>
 
+#define BNXT_MAX_CFA_CODE               65536
+#define BNXT_VF_IDX_INVALID             0xffff
+
+uint16_t
+bnxt_vfr_recv(struct bnxt *bp, uint16_t cfa_code, uint16_t queue_id,
+	      struct rte_mbuf *mbuf);
 int bnxt_vf_representor_init(struct rte_eth_dev *eth_dev, void *params);
 int bnxt_vf_representor_uninit(struct rte_eth_dev *eth_dev);
 int bnxt_vf_rep_dev_info_get_op(struct rte_eth_dev *eth_dev,
@@ -30,6 +36,11 @@ int bnxt_vf_rep_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
 				  __rte_unused unsigned int socket_id,
 				  __rte_unused const struct rte_eth_txconf *
 				  tx_conf);
+void bnxt_vf_rep_rx_queue_release_op(void *rx_queue);
+void bnxt_vf_rep_tx_queue_release_op(void *tx_queue);
 void bnxt_vf_rep_dev_stop_op(struct rte_eth_dev *eth_dev);
 void bnxt_vf_rep_dev_close_op(struct rte_eth_dev *eth_dev);
+int bnxt_vf_rep_stats_get_op(struct rte_eth_dev *eth_dev,
+			     struct rte_eth_stats *stats);
+int bnxt_vf_rep_stats_reset_op(struct rte_eth_dev *eth_dev);
 #endif /* _BNXT_REPS_H_ */
drivers/net/bnxt/bnxt_rxr.c +20 -2
index 11807f409..37b534fc2 100644
@@ -12,6 +12,7 @@
 #include <rte_memory.h>
 
 #include "bnxt.h"
+#include "bnxt_reps.h"
 #include "bnxt_ring.h"
 #include "bnxt_rxr.h"
 #include "bnxt_rxq.h"
@@ -539,7 +540,7 @@ void bnxt_set_mark_in_mbuf(struct bnxt *bp,
 }
 
 static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
-			    struct bnxt_rx_queue *rxq, uint32_t *raw_cons)
+		       struct bnxt_rx_queue *rxq, uint32_t *raw_cons)
 {
 	struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
 	struct bnxt_rx_ring_info *rxr = rxq->rx_ring;
@@ -735,6 +736,20 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
 rx:
 	*rx_pkt = mbuf;
 
+	if ((BNXT_VF_IS_TRUSTED(rxq->bp) || BNXT_PF(rxq->bp)) &&
+	    rxq->bp->cfa_code_map && rxcmp1->cfa_code) {
+		if (!bnxt_vfr_recv(rxq->bp, rxcmp1->cfa_code, rxq->queue_id,
+				   mbuf)) {
+			/* Now return an error so that nb_rx_pkts is not
+			 * incremented.
+			 * This packet was meant to be given to the representor.
+			 * So no need to account the packet and give it to
+			 * parent Rx burst function.
+			 */
+			rc = -ENODEV;
+		}
+	}
+
 next_rx:
 
 	*raw_cons = tmp_raw_cons;
@@ -751,6 +766,7 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	uint32_t raw_cons = cpr->cp_raw_cons;
 	uint32_t cons;
 	int nb_rx_pkts = 0;
+	int nb_rep_rx_pkts = 0;
 	struct rx_pkt_cmpl *rxcmp;
 	uint16_t prod = rxr->rx_prod;
 	uint16_t ag_prod = rxr->ag_prod;
@@ -784,6 +800,8 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 				nb_rx_pkts++;
 			if (rc == -EBUSY)	/* partial completion */
 				break;
+			if (rc == -ENODEV)	/* completion for representor */
+				nb_rep_rx_pkts++;
 		} else if (!BNXT_NUM_ASYNC_CPR(rxq->bp)) {
 			evt =
 			bnxt_event_hwrm_resp_handler(rxq->bp,
@@ -802,7 +820,7 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	}
 
 	cpr->cp_raw_cons = raw_cons;
-	if (!nb_rx_pkts && !evt) {
+	if (!nb_rx_pkts && !nb_rep_rx_pkts && !evt) {
 		/*
 		 * For PMD, there is no need to keep on pushing to REARM
 		 * the doorbell if there are no new completions
drivers/net/bnxt/bnxt_rxr.h +1 -0
index 811dcd86b..e60c97fa1 100644
@@ -188,6 +188,7 @@ struct bnxt_sw_rx_bd {
 struct bnxt_rx_ring_info {
 	uint16_t		rx_prod;
 	uint16_t		ag_prod;
+	uint16_t                rx_cons; /* Needed for representor */
 	struct bnxt_db_info     rx_db;
 	struct bnxt_db_info     ag_db;
 
drivers/net/bnxt/bnxt_txq.h +1 -0
index 37a3f9539..69ff89aab 100644
@@ -29,6 +29,7 @@ struct bnxt_tx_queue {
 	struct bnxt		*bp;
 	int			index;
 	int			tx_wake_thresh;
+	uint32_t                tx_cfa_action;
 	struct bnxt_tx_ring_info	*tx_ring;
 
 	unsigned int		cp_nr_rings;
drivers/net/bnxt/bnxt_txr.c +2 -2
index 16021407e..d7e193d38 100644
@@ -131,7 +131,7 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
 				PKT_TX_VLAN_PKT | PKT_TX_OUTER_IP_CKSUM |
 				PKT_TX_TUNNEL_GRE | PKT_TX_TUNNEL_VXLAN |
 				PKT_TX_TUNNEL_GENEVE | PKT_TX_IEEE1588_TMST |
-				PKT_TX_QINQ_PKT))
+				PKT_TX_QINQ_PKT) || txq->tx_cfa_action)
 		long_bd = true;
 
 	nr_bds = long_bd + tx_pkt->nb_segs;
@@ -184,7 +184,7 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
 	if (long_bd) {
 		txbd->flags_type |= TX_BD_LONG_TYPE_TX_BD_LONG;
 		vlan_tag_flags = 0;
-		cfa_action = 0;
+		cfa_action = txq->tx_cfa_action;
 		/* HW can accelerate only outer vlan in QinQ mode */
 		if (tx_buf->mbuf->ol_flags & PKT_TX_QINQ_PKT) {
 			vlan_tag_flags = TX_BD_LONG_CFA_META_KEY_VLAN_TAG |
Signature · 1 line
2.21.1 (Apple Git-122.3)
#216 lore raw

PATCH v5 3/51 net/bnxt: get IDs for VF-Rep endpoint

In reply to Ajit Khaparde

From: Somnath Kotur <[email protected]>

Use 'first_vf_id' and the 'vf_id' that is input as part of adding a representor to obtain the PCI function ID(FID) of the VF(VFR endpoint). Use the FID as an input to FUNC_QCFG HWRM cmd to obtain the default vnic ID of the VF.
Along with getting the default vNIC ID by supplying the FW FID of the VF-rep endpoint to HWRM_FUNC_QCFG, obtain and store it's function svif.

---
 drivers/net/bnxt/bnxt.h      |  3 +++
 drivers/net/bnxt/bnxt_hwrm.c | 27 +++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.h |  4 ++++
 drivers/net/bnxt/bnxt_reps.c | 12 ++++++++++++
 4 files changed, 46 insertions(+)
drivers/net/bnxt/bnxt.h +3 -0
index 443d9fee4..7afbd5cab 100644
@@ -784,6 +784,9 @@ struct bnxt {
 struct bnxt_vf_representor {
 	uint16_t		switch_domain_id;
 	uint16_t		vf_id;
+	uint16_t		fw_fid;
+	uint16_t		dflt_vnic_id;
+	uint16_t		svif;
 	uint16_t		tx_cfa_action;
 	uint16_t		rx_cfa_code;
 	/* Private data store of associated PF/Trusted VF */
drivers/net/bnxt/bnxt_hwrm.c +27 -0
index 945bc9018..ed42e58d4 100644
@@ -3094,6 +3094,33 @@ int bnxt_hwrm_func_qcfg(struct bnxt *bp, uint16_t *mtu)
 	return rc;
 }
 
+int bnxt_hwrm_get_dflt_vnic_svif(struct bnxt *bp, uint16_t fid,
+				 uint16_t *vnic_id, uint16_t *svif)
+{
+	struct hwrm_func_qcfg_input req = {0};
+	struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
+	uint16_t svif_info;
+	int rc = 0;
+
+	HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
+	req.fid = rte_cpu_to_le_16(fid);
+
+	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+
+	HWRM_CHECK_RESULT();
+
+	if (vnic_id)
+		*vnic_id = rte_le_to_cpu_16(resp->dflt_vnic_id);
+
+	svif_info = rte_le_to_cpu_16(resp->svif_info);
+	if (svif && (svif_info & HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_VALID))
+		*svif = svif_info & HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_MASK;
+
+	HWRM_UNLOCK();
+
+	return rc;
+}
+
 int bnxt_hwrm_port_mac_qcfg(struct bnxt *bp)
 {
 	struct hwrm_port_mac_qcfg_input req = {0};
drivers/net/bnxt/bnxt_hwrm.h +4 -0
index 58b414d4f..8d19998df 100644
@@ -270,4 +270,8 @@ int bnxt_hwrm_cfa_counter_qstats(struct bnxt *bp,
 				 enum bnxt_flow_dir dir,
 				 uint16_t cntr,
 				 uint16_t num_entries);
+int bnxt_hwrm_get_dflt_vnic_id(struct bnxt *bp, uint16_t fid,
+			       uint16_t *vnic_id);
+int bnxt_hwrm_get_dflt_vnic_svif(struct bnxt *bp, uint16_t fid,
+				 uint16_t *vnic_id, uint16_t *svif);
 #endif
drivers/net/bnxt/bnxt_reps.c +12 -0
index 777179558..ea6f0010f 100644
@@ -150,6 +150,7 @@ int bnxt_vf_representor_init(struct rte_eth_dev *eth_dev, void *params)
 				 (struct bnxt_vf_representor *)params;
 	struct rte_eth_link *link;
 	struct bnxt *parent_bp;
+	int rc = 0;
 
 	vf_rep_bp->vf_id = rep_params->vf_id;
 	vf_rep_bp->switch_domain_id = rep_params->switch_domain_id;
@@ -179,6 +180,17 @@ int bnxt_vf_representor_init(struct rte_eth_dev *eth_dev, void *params)
 	eth_dev->data->dev_link.link_status = link->link_status;
 	eth_dev->data->dev_link.link_autoneg = link->link_autoneg;
 
+	vf_rep_bp->fw_fid = rep_params->vf_id + parent_bp->first_vf_id;
+	PMD_DRV_LOG(INFO, "vf_rep->fw_fid = %d\n", vf_rep_bp->fw_fid);
+	rc = bnxt_hwrm_get_dflt_vnic_svif(parent_bp, vf_rep_bp->fw_fid,
+					  &vf_rep_bp->dflt_vnic_id,
+					  &vf_rep_bp->svif);
+	if (rc)
+		PMD_DRV_LOG(ERR, "Failed to get default vnic id of VF\n");
+	else
+		PMD_DRV_LOG(INFO, "vf_rep->dflt_vnic_id = %d\n",
+			    vf_rep_bp->dflt_vnic_id);
+
 	PMD_DRV_LOG(INFO, "calling bnxt_print_link_info\n");
 	bnxt_print_link_info(eth_dev);
 
Signature · 1 line
2.21.1 (Apple Git-122.3)
#217 lore raw

PATCH v5 4/51 net/bnxt: initialize parent PF information

In reply to Ajit Khaparde

From: Lance Richardson <[email protected]>

Add support to query parent PF information (MAC address, function ID, port ID and default VNIC) from firmware.

Current firmware returns zero for parent default vnic, a temporary Wh+-specific workaround is included until that can be fixed.

---
 drivers/net/bnxt/bnxt.h        |  9 ++++++++
 drivers/net/bnxt/bnxt_ethdev.c | 23 +++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.c   | 42 ++++++++++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.h   |  1 +
 4 files changed, 75 insertions(+)
drivers/net/bnxt/bnxt.h +9 -0
index 7afbd5cab..2b87899a4 100644
@@ -217,6 +217,14 @@ struct bnxt_child_vf_info {
 	bool			persist_stats;
 };
 
+struct bnxt_parent_info {
+#define	BNXT_PF_FID_INVALID	0xFFFF
+	uint16_t		fid;
+	uint16_t		vnic;
+	uint16_t		port_id;
+	uint8_t			mac_addr[RTE_ETHER_ADDR_LEN];
+};
+
 struct bnxt_pf_info {
 #define BNXT_FIRST_PF_FID	1
 #define BNXT_MAX_VFS(bp)	((bp)->pf->max_vfs)
@@ -738,6 +746,7 @@ struct bnxt {
 #define BNXT_OUTER_TPID_BD_SHFT	16
 	uint32_t		outer_tpid_bd;
 	struct bnxt_pf_info	*pf;
+	struct bnxt_parent_info	*parent;
 	uint8_t			vxlan_port_cnt;
 	uint8_t			geneve_port_cnt;
 	uint16_t		vxlan_port;
drivers/net/bnxt/bnxt_ethdev.c +23 -0
index cddba17bd..b765cbadb 100644
@@ -96,6 +96,7 @@ static const struct rte_pci_id bnxt_pci_id_map[] = {
 #define BNXT_DEVARG_TRUFLOW	"host-based-truflow"
 #define BNXT_DEVARG_FLOW_XSTAT	"flow-xstat"
 #define BNXT_DEVARG_MAX_NUM_KFLOWS  "max-num-kflows"
+
 static const char *const bnxt_dev_args[] = {
 	BNXT_DEVARG_TRUFLOW,
 	BNXT_DEVARG_FLOW_XSTAT,
@@ -172,6 +173,11 @@ uint16_t bnxt_rss_hash_tbl_size(const struct bnxt *bp)
 	return bnxt_rss_ctxts(bp) * BNXT_RSS_ENTRIES_PER_CTX_THOR;
 }
 
+static void bnxt_free_parent_info(struct bnxt *bp)
+{
+	rte_free(bp->parent);
+}
+
 static void bnxt_free_pf_info(struct bnxt *bp)
 {
 	rte_free(bp->pf);
@@ -222,6 +228,16 @@ static void bnxt_free_mem(struct bnxt *bp, bool reconfig)
 	bp->grp_info = NULL;
 }
 
+static int bnxt_alloc_parent_info(struct bnxt *bp)
+{
+	bp->parent = rte_zmalloc("bnxt_parent_info",
+				 sizeof(struct bnxt_parent_info), 0);
+	if (bp->parent == NULL)
+		return -ENOMEM;
+
+	return 0;
+}
+
 static int bnxt_alloc_pf_info(struct bnxt *bp)
 {
 	bp->pf = rte_zmalloc("bnxt_pf_info", sizeof(struct bnxt_pf_info), 0);
@@ -1321,6 +1337,7 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
 	bnxt_free_cos_queues(bp);
 	bnxt_free_link_info(bp);
 	bnxt_free_pf_info(bp);
+	bnxt_free_parent_info(bp);
 
 	eth_dev->dev_ops = NULL;
 	eth_dev->rx_pkt_burst = NULL;
@@ -5209,6 +5226,8 @@ static int bnxt_init_fw(struct bnxt *bp)
 
 	bnxt_hwrm_port_mac_qcfg(bp);
 
+	bnxt_hwrm_parent_pf_qcfg(bp);
+
 	rc = bnxt_hwrm_cfa_adv_flow_mgmt_qcaps(bp);
 	if (rc)
 		return rc;
@@ -5527,6 +5546,10 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev, void *params __rte_unused)
 	if (rc)
 		goto error_free;
 
+	rc = bnxt_alloc_parent_info(bp);
+	if (rc)
+		goto error_free;
+
 	rc = bnxt_alloc_hwrm_resources(bp);
 	if (rc) {
 		PMD_DRV_LOG(ERR,
drivers/net/bnxt/bnxt_hwrm.c +42 -0

48 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.h +1 -0
index 8d19998df..ef8997500 100644
@@ -274,4 +274,5 @@ int bnxt_hwrm_get_dflt_vnic_id(struct bnxt *bp, uint16_t fid,
 			       uint16_t *vnic_id);
 int bnxt_hwrm_get_dflt_vnic_svif(struct bnxt *bp, uint16_t fid,
 				 uint16_t *vnic_id, uint16_t *svif);
+int bnxt_hwrm_parent_pf_qcfg(struct bnxt *bp);
 #endif
Signature · 1 line
2.21.1 (Apple Git-122.3)
#218 lore raw

PATCH v5 5/51 net/bnxt: modify port db dev interface

In reply to Ajit Khaparde

From: Venkat Duvvuru <[email protected]>

Modify ulp_port_db_dev_port_intf_update prototype to take "struct rte_eth_dev *" as the second parameter.

---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c    | 4 ++--
 drivers/net/bnxt/tf_ulp/ulp_port_db.c | 5 +++--
 drivers/net/bnxt/tf_ulp/ulp_port_db.h | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +2 -2
index 0c3c638ce..c7281ab9a 100644
@@ -548,7 +548,7 @@ bnxt_ulp_init(struct bnxt *bp)
 		}
 
 		/* update the port database */
-		rc = ulp_port_db_dev_port_intf_update(bp->ulp_ctx, bp);
+		rc = ulp_port_db_dev_port_intf_update(bp->ulp_ctx, bp->eth_dev);
 		if (rc) {
 			BNXT_TF_DBG(ERR,
 				    "Failed to update port database\n");
@@ -584,7 +584,7 @@ bnxt_ulp_init(struct bnxt *bp)
 	}
 
 	/* update the port database */
-	rc = ulp_port_db_dev_port_intf_update(bp->ulp_ctx, bp);
+	rc = ulp_port_db_dev_port_intf_update(bp->ulp_ctx, bp->eth_dev);
 	if (rc) {
 		BNXT_TF_DBG(ERR, "Failed to update port database\n");
 		goto jump_to_error;
drivers/net/bnxt/tf_ulp/ulp_port_db.c +3 -2
index e3b924289..66b584026 100644
@@ -104,10 +104,11 @@ int32_t	ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt)
  * Returns 0 on success or negative number on failure.
  */
 int32_t	ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
-					 struct bnxt *bp)
+					 struct rte_eth_dev *eth_dev)
 {
 	struct bnxt_ulp_port_db *port_db;
-	uint32_t port_id = bp->eth_dev->data->port_id;
+	struct bnxt *bp = eth_dev->data->dev_private;
+	uint32_t port_id = eth_dev->data->port_id;
 	uint32_t ifindex;
 	struct ulp_interface_info *intf;
 	int32_t rc;
drivers/net/bnxt/tf_ulp/ulp_port_db.h +1 -1
index 271c29a47..929a5a510 100644
@@ -71,7 +71,7 @@ int32_t	ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt);
  * Returns 0 on success or negative number on failure.
  */
 int32_t	ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
-					 struct bnxt *bp);
+					 struct rte_eth_dev *eth_dev);
 
 /*
  * Api to get the ulp ifindex for a given device port.
Signature · 1 line
2.21.1 (Apple Git-122.3)
#219 lore raw

PATCH v5 6/51 net/bnxt: get port and function info

In reply to Ajit Khaparde

From: Venkat Duvvuru <[email protected]>

add helper functions to get port & function related information like parif, physical port id & vport id.

---
 drivers/net/bnxt/bnxt.h                  |  8 ++++
 drivers/net/bnxt/bnxt_ethdev.c           | 58 ++++++++++++++++++++++++
 drivers/net/bnxt/tf_ulp/bnxt_tf_common.h | 10 ++++
 drivers/net/bnxt/tf_ulp/ulp_port_db.h    | 10 ----
 4 files changed, 76 insertions(+), 10 deletions(-)
drivers/net/bnxt/bnxt.h +8 -0
index 2b87899a4..0bdf8f5ba 100644
@@ -855,6 +855,9 @@ extern const struct rte_flow_ops bnxt_flow_ops;
 	} \
 } while (0)
 
+#define	BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)	\
+		((eth_dev)->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+
 extern int bnxt_logtype_driver;
 #define PMD_DRV_LOG_RAW(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, bnxt_logtype_driver, "%s(): " fmt, \
@@ -870,6 +873,11 @@ void bnxt_ulp_deinit(struct bnxt *bp);
 uint16_t bnxt_get_vnic_id(uint16_t port);
 uint16_t bnxt_get_svif(uint16_t port_id, bool func_svif);
 uint16_t bnxt_get_fw_func_id(uint16_t port);
+uint16_t bnxt_get_parif(uint16_t port);
+uint16_t bnxt_get_phy_port_id(uint16_t port);
+uint16_t bnxt_get_vport(uint16_t port);
+enum bnxt_ulp_intf_type
+bnxt_get_interface_type(uint16_t port);
 
 void bnxt_cancel_fc_thread(struct bnxt *bp);
 void bnxt_flow_cnt_alarm_cb(void *arg);
drivers/net/bnxt/bnxt_ethdev.c +58 -0

70 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/bnxt_tf_common.h +10 -0
index f41757908..f772d4919 100644
@@ -44,6 +44,16 @@ enum ulp_direction_type {
 	ULP_DIR_EGRESS,
 };
 
+/* enumeration of the interface types */
+enum bnxt_ulp_intf_type {
+	BNXT_ULP_INTF_TYPE_INVALID = 0,
+	BNXT_ULP_INTF_TYPE_PF,
+	BNXT_ULP_INTF_TYPE_VF,
+	BNXT_ULP_INTF_TYPE_PF_REP,
+	BNXT_ULP_INTF_TYPE_VF_REP,
+	BNXT_ULP_INTF_TYPE_LAST
+};
+
 struct bnxt_ulp_mark_tbl *
 bnxt_ulp_cntxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx);
 
drivers/net/bnxt/tf_ulp/ulp_port_db.h +0 -10
index 929a5a510..604c4385a 100644
@@ -10,16 +10,6 @@
 
 #define BNXT_PORT_DB_MAX_INTF_LIST		256
 
-/* enumeration of the interface types */
-enum bnxt_ulp_intf_type {
-	BNXT_ULP_INTF_TYPE_INVALID = 0,
-	BNXT_ULP_INTF_TYPE_PF = 1,
-	BNXT_ULP_INTF_TYPE_VF,
-	BNXT_ULP_INTF_TYPE_PF_REP,
-	BNXT_ULP_INTF_TYPE_VF_REP,
-	BNXT_ULP_INTF_TYPE_LAST
-};
-
 /* Structure for the Port database resource information. */
 struct ulp_interface_info {
 	enum bnxt_ulp_intf_type	type;
Signature · 1 line
2.21.1 (Apple Git-122.3)
#220 lore raw

PATCH v5 7/51 net/bnxt: add support for hwrm port phy qcaps

In reply to Ajit Khaparde

From: Venkat Duvvuru <[email protected]>

Issue HWRM_PORT_PHY_QCAPS to the firmware to get the physical port count of the device.

---
 drivers/net/bnxt/bnxt.h        |  1 +
 drivers/net/bnxt/bnxt_ethdev.c |  2 ++
 drivers/net/bnxt/bnxt_hwrm.c   | 22 ++++++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.h   |  1 +
 4 files changed, 26 insertions(+)
drivers/net/bnxt/bnxt.h +1 -0
index 0bdf8f5ba..65862abdc 100644
@@ -747,6 +747,7 @@ struct bnxt {
 	uint32_t		outer_tpid_bd;
 	struct bnxt_pf_info	*pf;
 	struct bnxt_parent_info	*parent;
+	uint8_t			port_cnt;
 	uint8_t			vxlan_port_cnt;
 	uint8_t			geneve_port_cnt;
 	uint16_t		vxlan_port;
drivers/net/bnxt/bnxt_ethdev.c +2 -0
index a2adf15b0..72cc2daa6 100644
@@ -5286,6 +5286,8 @@ static int bnxt_init_fw(struct bnxt *bp)
 
 	bnxt_hwrm_parent_pf_qcfg(bp);
 
+	bnxt_hwrm_port_phy_qcaps(bp);
+
 	rc = bnxt_hwrm_cfa_adv_flow_mgmt_qcaps(bp);
 	if (rc)
 		return rc;
drivers/net/bnxt/bnxt_hwrm.c +22 -0
index 347e1c71e..e6a28d07c 100644
@@ -1330,6 +1330,28 @@ static int bnxt_hwrm_port_phy_qcfg(struct bnxt *bp,
 	return rc;
 }
 
+int bnxt_hwrm_port_phy_qcaps(struct bnxt *bp)
+{
+	int rc = 0;
+	struct hwrm_port_phy_qcaps_input req = {0};
+	struct hwrm_port_phy_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
+
+	if (BNXT_VF(bp) && !BNXT_VF_IS_TRUSTED(bp))
+		return 0;
+
+	HWRM_PREP(&req, HWRM_PORT_PHY_QCAPS, BNXT_USE_CHIMP_MB);
+
+	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+
+	HWRM_CHECK_RESULT();
+
+	bp->port_cnt = resp->port_cnt;
+
+	HWRM_UNLOCK();
+
+	return 0;
+}
+
 static bool bnxt_find_lossy_profile(struct bnxt *bp)
 {
 	int i = 0;
drivers/net/bnxt/bnxt_hwrm.h +1 -0
index ef8997500..87cd40779 100644
@@ -275,4 +275,5 @@ int bnxt_hwrm_get_dflt_vnic_id(struct bnxt *bp, uint16_t fid,
 int bnxt_hwrm_get_dflt_vnic_svif(struct bnxt *bp, uint16_t fid,
 				 uint16_t *vnic_id, uint16_t *svif);
 int bnxt_hwrm_parent_pf_qcfg(struct bnxt *bp);
+int bnxt_hwrm_port_phy_qcaps(struct bnxt *bp);
 #endif
Signature · 1 line
2.21.1 (Apple Git-122.3)
#221 lore raw

PATCH v5 8/51 net/bnxt: modify port db to handle more info

In reply to Ajit Khaparde

From: Venkat Duvvuru <[email protected]>

Apart from func_svif, func_id & vnic, port_db now stores and retrieves func_spif, func_parif, phy_port_id, port_svif, port_spif, port_parif, port_vport. New helper functions have been added to support the same.

---
 drivers/net/bnxt/tf_ulp/ulp_port_db.c | 145 +++++++++++++++++++++-----
 drivers/net/bnxt/tf_ulp/ulp_port_db.h |  72 ++++++++++---
 2 files changed, 179 insertions(+), 38 deletions(-)
drivers/net/bnxt/tf_ulp/ulp_port_db.c +121 -24
index 66b584026..ea27ef41f 100644
@@ -106,13 +106,12 @@ int32_t	ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt)
 int32_t	ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
 					 struct rte_eth_dev *eth_dev)
 {
-	struct bnxt_ulp_port_db *port_db;
-	struct bnxt *bp = eth_dev->data->dev_private;
 	uint32_t port_id = eth_dev->data->port_id;
-	uint32_t ifindex;
+	struct ulp_phy_port_info *port_data;
+	struct bnxt_ulp_port_db *port_db;
 	struct ulp_interface_info *intf;
+	uint32_t ifindex;
 	int32_t rc;
-	struct bnxt_vnic_info *vnic;
 
 	port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);
 	if (!port_db) {
@@ -133,22 +132,22 @@ int32_t	ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt,
 
 	/* update the interface details */
 	intf = &port_db->ulp_intf_list[ifindex];
-	if (BNXT_PF(bp) || BNXT_VF(bp)) {
-		if (BNXT_PF(bp)) {
-			intf->type = BNXT_ULP_INTF_TYPE_PF;
-			intf->port_svif = bp->port_svif;
-		} else {
-			intf->type = BNXT_ULP_INTF_TYPE_VF;
-		}
-		intf->func_id = bp->fw_fid;
-		intf->func_svif = bp->func_svif;
-		vnic = BNXT_GET_DEFAULT_VNIC(bp);
-		if (vnic)
-			intf->default_vnic = vnic->fw_vnic_id;
-		intf->bp = bp;
-		memcpy(intf->mac_addr, bp->mac_addr, sizeof(intf->mac_addr));
-	} else {
-		BNXT_TF_DBG(ERR, "Invalid interface type\n");
+
+	intf->type = bnxt_get_interface_type(port_id);
+
+	intf->func_id = bnxt_get_fw_func_id(port_id);
+	intf->func_svif = bnxt_get_svif(port_id, 1);
+	intf->func_spif = bnxt_get_phy_port_id(port_id);
+	intf->func_parif = bnxt_get_parif(port_id);
+	intf->default_vnic = bnxt_get_vnic_id(port_id);
+	intf->phy_port_id = bnxt_get_phy_port_id(port_id);
+
+	if (intf->type == BNXT_ULP_INTF_TYPE_PF) {
+		port_data = &port_db->phy_port_list[intf->phy_port_id];
+		port_data->port_svif = bnxt_get_svif(port_id, 0);
+		port_data->port_spif = bnxt_get_phy_port_id(port_id);
+		port_data->port_parif = bnxt_get_parif(port_id);
+		port_data->port_vport = bnxt_get_vport(port_id);
 	}
 
 	return 0;
@@ -209,7 +208,7 @@ ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt,
 }
 
 /*
- * Api to get the svid for a given ulp ifindex.
+ * Api to get the svif for a given ulp ifindex.
  *
  * ulp_ctxt [in] Ptr to ulp context
  * ifindex [in] ulp ifindex
@@ -225,16 +224,88 @@ ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt,
 		     uint16_t *svif)
 {
 	struct bnxt_ulp_port_db *port_db;
+	uint16_t phy_port_id;
 
 	port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);
 	if (!port_db || ifindex >= port_db->ulp_intf_list_size || !ifindex) {
 		BNXT_TF_DBG(ERR, "Invalid Arguments\n");
 		return -EINVAL;
 	}
-	if (dir == ULP_DIR_EGRESS)
+	if (dir == ULP_DIR_EGRESS) {
 		*svif = port_db->ulp_intf_list[ifindex].func_svif;
-	else
-		*svif = port_db->ulp_intf_list[ifindex].port_svif;
+	} else {
+		phy_port_id = port_db->ulp_intf_list[ifindex].phy_port_id;
+		*svif = port_db->phy_port_list[phy_port_id].port_svif;
+	}
+
+	return 0;
+}
+
+/*
+ * Api to get the spif for a given ulp ifindex.
+ *
+ * ulp_ctxt [in] Ptr to ulp context
+ * ifindex [in] ulp ifindex
+ * dir [in] the direction for the flow.
+ * spif [out] the spif of the given ifindex.
+ *
+ * Returns 0 on success or negative number on failure.
+ */
+int32_t
+ulp_port_db_spif_get(struct bnxt_ulp_context *ulp_ctxt,
+		     uint32_t ifindex,
+		     uint32_t dir,
+		     uint16_t *spif)
+{
+	struct bnxt_ulp_port_db *port_db;
+	uint16_t phy_port_id;
+
+	port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);
+	if (!port_db || ifindex >= port_db->ulp_intf_list_size || !ifindex) {
+		BNXT_TF_DBG(ERR, "Invalid Arguments\n");
+		return -EINVAL;
+	}
+	if (dir == ULP_DIR_EGRESS) {
+		*spif = port_db->ulp_intf_list[ifindex].func_spif;
+	} else {
+		phy_port_id = port_db->ulp_intf_list[ifindex].phy_port_id;
+		*spif = port_db->phy_port_list[phy_port_id].port_spif;
+	}
+
+	return 0;
+}
+
+/*
+ * Api to get the parif for a given ulp ifindex.
+ *
+ * ulp_ctxt [in] Ptr to ulp context
+ * ifindex [in] ulp ifindex
+ * dir [in] the direction for the flow.
+ * parif [out] the parif of the given ifindex.
+ *
+ * Returns 0 on success or negative number on failure.
+ */
+int32_t
+ulp_port_db_parif_get(struct bnxt_ulp_context *ulp_ctxt,
+		     uint32_t ifindex,
+		     uint32_t dir,
+		     uint16_t *parif)
+{
+	struct bnxt_ulp_port_db *port_db;
+	uint16_t phy_port_id;
+
+	port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);
+	if (!port_db || ifindex >= port_db->ulp_intf_list_size || !ifindex) {
+		BNXT_TF_DBG(ERR, "Invalid Arguments\n");
+		return -EINVAL;
+	}
+	if (dir == ULP_DIR_EGRESS) {
+		*parif = port_db->ulp_intf_list[ifindex].func_parif;
+	} else {
+		phy_port_id = port_db->ulp_intf_list[ifindex].phy_port_id;
+		*parif = port_db->phy_port_list[phy_port_id].port_parif;
+	}
+
 	return 0;
 }
 
@@ -262,3 +333,29 @@ ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt,
 	*vnic = port_db->ulp_intf_list[ifindex].default_vnic;
 	return 0;
 }
+
+/*
+ * Api to get the vport id for a given ulp ifindex.
+ *
+ * ulp_ctxt [in] Ptr to ulp context
+ * ifindex [in] ulp ifindex
+ * vport [out] the port of the given ifindex.
+ *
+ * Returns 0 on success or negative number on failure.
+ */
+int32_t
+ulp_port_db_vport_get(struct bnxt_ulp_context *ulp_ctxt,
+		      uint32_t ifindex, uint16_t *vport)
+{
+	struct bnxt_ulp_port_db *port_db;
+	uint16_t phy_port_id;
+
+	port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt);
+	if (!port_db || ifindex >= port_db->ulp_intf_list_size || !ifindex) {
+		BNXT_TF_DBG(ERR, "Invalid Arguments\n");
+		return -EINVAL;
+	}
+	phy_port_id = port_db->ulp_intf_list[ifindex].phy_port_id;
+	*vport = port_db->phy_port_list[phy_port_id].port_vport;
+	return 0;
+}
drivers/net/bnxt/tf_ulp/ulp_port_db.h +58 -14

110 lines not on this page · raw message

Signature · 1 line
2.21.1 (Apple Git-122.3)