Skip to contentSkip to conversation

net/bnxt: fix tunnel port accounting

PATCH In review Ajit Khaparde 1 participant 2 messages Sep 27, 2021 – Sep 29, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/bnxt: fix tunnel port accounting

Fix the tunnel port counting logic.
Currently we are incrementing the port count without checking the if bnxt_hwrm_tunnel_dst_port_alloc would return success or failure. Modify the logic to increment it only if the firmware returns success.

Fixes 10d074b2022d ("net/bnxt: support tunneling")
---
 drivers/net/bnxt/bnxt_ethdev.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +12 -2
index 857da91c9d..aa7e7fdc85 100644
@@ -2369,7 +2369,6 @@ bnxt_udp_tunnel_port_add_op(struct rte_eth_dev *eth_dev,
 		}
 		tunnel_type =
 			HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_VXLAN;
-		bp->vxlan_port_cnt++;
 		break;
 	case RTE_TUNNEL_TYPE_GENEVE:
 		if (bp->geneve_port_cnt) {
@@ -2384,7 +2383,6 @@ bnxt_udp_tunnel_port_add_op(struct rte_eth_dev *eth_dev,
 		}
 		tunnel_type =
 			HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_GENEVE;
-		bp->geneve_port_cnt++;
 		break;
 	default:
 		PMD_DRV_LOG(ERR, "Tunnel type is not supported\n");
@@ -2392,6 +2390,18 @@ bnxt_udp_tunnel_port_add_op(struct rte_eth_dev *eth_dev,
 	}
 	rc = bnxt_hwrm_tunnel_dst_port_alloc(bp, udp_tunnel->udp_port,
 					     tunnel_type);
+
+	if (rc != 0)
+		return rc;
+
+	if (tunnel_type ==
+	    HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_VXLAN)
+		bp->vxlan_port_cnt++;
+
+	if (tunnel_type ==
+	    HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_GENEVE)
+		bp->geneve_port_cnt++;
+
 	return rc;
 }
 
Signature · 1 line
2.30.1 (Apple Git-130)
#1 lore raw
Quoted 11 lines · Ajit Khaparde

Fix the tunnel port counting logic.
Currently we are incrementing the port count without checking the if bnxt_hwrm_tunnel_dst_port_alloc would return success or failure. Modify the logic to increment it only if the firmware returns success.

Fixes 10d074b2022d ("net/bnxt: support tunneling")

Patch applied to dpdk-next-net-brcm.