[v4,01/47] net/bnxt: tf_core: fix wc tcam multi slice delete issue

Message ID 20241004175338.3156160-2-sriharsha.basavapatna@broadcom.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ajit Khaparde
Headers
Series TruFlow update for Thor2 |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Sriharsha Basavapatna Oct. 4, 2024, 5:52 p.m. UTC
From: Shahaji Bhosle <sbhosle@broadcom.com>

FW tries to update the HWRM request data in the
delete case to update the mode bit and also
update invalid profile id. This update only
happens when the data is send over DMA. HWRM
requests are read only buffers and cannot be
updated. So driver now will always send WC
tcam set message over DMA channel.

Update tunnel alloc apis to provide error message.

Fixes: ca5e61bd562d ("net/bnxt: support EM and TCAM lookup with table scope")
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
Reviewed-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Shahaji Bhosle <sbhosle@broadcom.com>
Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_msg.c          | 28 +++++++++++-----------
 drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c | 18 ++++++++++++--
 2 files changed, 30 insertions(+), 16 deletions(-)
  

Comments

Stephen Hemminger Oct. 14, 2024, 7:41 p.m. UTC | #1
On Fri,  4 Oct 2024 23:22:52 +0530
Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com> wrote:

> From: Shahaji Bhosle <sbhosle@broadcom.com>
> 
> FW tries to update the HWRM request data in the
> delete case to update the mode bit and also
> update invalid profile id. This update only
> happens when the data is send over DMA. HWRM
> requests are read only buffers and cannot be
> updated. So driver now will always send WC
> tcam set message over DMA channel.
> 
> Update tunnel alloc apis to provide error message.
> 
> Fixes: ca5e61bd562d ("net/bnxt: support EM and TCAM lookup with table scope")
> Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
> Reviewed-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
> Signed-off-by: Shahaji Bhosle <sbhosle@broadcom.com>
> Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
> Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> ---

The patch series needs to be rebased, there is some fuzz and git doesn't like to apply.

Also, not every patch builds. For example after applying the first patch
the build fails with:


../drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c: In function ‘bnxt_tunnel_dst_port_alloc’:
../drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c:40:17: error: implicit declaration of function ‘PMD_DRV_LOG’; did you mean ‘PMD_DRV_LOG_LINE’? [-Wimplicit-function-declaration]
   40 |                 PMD_DRV_LOG(ERR, "Tunnel type:%d alloc failed for port:%d error:%s\n",
      |                 ^~~~~~~~~~~
      |                 PMD_DRV_LOG_LINE
../drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c:40:17: warning: nested extern declaration of ‘PMD_DRV_LOG’ [-Wnested-externs]
../drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c:40:29: error: ‘ERR’ undeclared (first use in this function)
   40 |                 PMD_DRV_LOG(ERR, "Tunnel type:%d alloc failed for port:%d error:%s\n",
      |                             ^~~
../drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c:40:29: note: each undeclared identifier is reported only once for each function it appears in
../drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c: In function ‘bnxt_pmd_global_tunnel_set’:
../drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c:601:37: error: ‘ERR’ undeclared (first use in this function)
  601 |                         PMD_DRV_LOG(ERR, "Tunnel type:%d alloc failed for port:%d error:%s\n",
      |                                     ^~~
[16/2343] Compiling C object drivers/libtmp_rte_net_bnxt.a.p/net_bnxt_tf_ulp_ulp_mapper.c.o
  

Patch

diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c
index 1c66c7e01a..4aa90f6b07 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -1612,20 +1612,20 @@  tf_msg_tcam_entry_set(struct tf *tfp,
 	req.result_size = parms->result_size;
 	data_size = 2 * req.key_size + req.result_size;
 
-	if (data_size <= TF_PCI_BUF_SIZE_MAX) {
-		/* use pci buffer */
-		data = &req.dev_data[0];
-	} else {
-		/* use dma buffer */
-		req.flags |= HWRM_TF_TCAM_SET_INPUT_FLAGS_DMA;
-		rc = tf_msg_alloc_dma_buf(&buf, data_size);
-		if (rc)
-			goto cleanup;
-		data = buf.va_addr;
-		tfp_memcpy(&req.dev_data[0],
-			   &buf.pa_addr,
-			   sizeof(buf.pa_addr));
-	}
+	/*
+	 * Always use dma buffer, as the delete multi slice
+	 * tcam entries not support with HWRM request buffer
+	 * only DMA'ed buffer can update the mode bits for
+	 * the delete to work
+	 */
+	req.flags |= HWRM_TF_TCAM_SET_INPUT_FLAGS_DMA;
+	rc = tf_msg_alloc_dma_buf(&buf, data_size);
+	if (rc)
+		goto cleanup;
+	data = buf.va_addr;
+	tfp_memcpy(&req.dev_data[0],
+		   &buf.pa_addr,
+		   sizeof(buf.pa_addr));
 
 	tfp_memcpy(&data[0], parms->key, parms->key_size);
 	tfp_memcpy(&data[parms->key_size], parms->mask, parms->key_size);
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c b/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c
index 96d61c3ed2..7e4952c062 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c
@@ -32,9 +32,17 @@  bnxt_tunnel_dst_port_alloc(struct bnxt *bp,
 			   uint16_t port,
 			   uint8_t type)
 {
-	return bnxt_hwrm_tunnel_dst_port_alloc(bp,
+	int rc = 0;
+	rc = bnxt_hwrm_tunnel_dst_port_alloc(bp,
 					       port,
 					       type);
+	if (rc) {
+		PMD_DRV_LOG(ERR, "Tunnel type:%d alloc failed for port:%d error:%s\n",
+			    type, port,
+			    (rc == HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_ERROR_INFO_ERR_ALLOCATED) ?
+			    "already allocated" : "no resource");
+	}
+	return rc;
 }
 
 int
@@ -589,7 +597,13 @@  bnxt_pmd_global_tunnel_set(uint16_t port_id, uint8_t type,
 		}
 
 		rc = bnxt_hwrm_tunnel_dst_port_alloc(bp, udp_port, hwtype);
-		if (!rc) {
+		if (rc) {
+			PMD_DRV_LOG(ERR, "Tunnel type:%d alloc failed for port:%d error:%s\n",
+				    hwtype, udp_port,
+				    (rc ==
+				     HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_ERROR_INFO_ERR_ALLOCATED) ?
+				    "already allocated" : "no resource");
+		} else {
 			ulp_global_tunnel_db[type].ref_cnt++;
 			ulp_global_tunnel_db[type].dport = udp_port;
 			bnxt_pmd_global_reg_data_to_hndl(port_id, bp->ecpri_upar_in_use,