net/bnxt: fix a segfault during Tx

Message ID 20200713051759.18901-1-somnath.kotur@broadcom.com (mailing list archive)
State Accepted, archived
Delegated to: Ajit Khaparde
Headers
Series net/bnxt: fix a segfault during Tx |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Performance-Testing fail build patch failure
ci/travis-robot warning Travis build: failed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Somnath Kotur July 13, 2020, 5:17 a.m. UTC
  From: Ajit Khaparde <ajit.khaparde@broadcom.com>

When TRUFLOW is not enabled ulp_ctx is not allocated.
In non-vector Tx datapath we are accessing this invalid pointer
resulting in a segfault. Check if TRUFLOW is enabled before
accessing ulp_ctx to avoid this.

Fixes: f86dc320a894 ("net/bnxt: fill cfa action in Tx descriptor")

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
---
 drivers/net/bnxt/bnxt_txr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Ajit Khaparde July 14, 2020, 10:02 p.m. UTC | #1
On Sun, Jul 12, 2020 at 10:23 PM Somnath Kotur <somnath.kotur@broadcom.com>
wrote:

> From: Ajit Khaparde <ajit.khaparde@broadcom.com>
>
> When TRUFLOW is not enabled ulp_ctx is not allocated.
> In non-vector Tx datapath we are accessing this invalid pointer
> resulting in a segfault. Check if TRUFLOW is enabled before
> accessing ulp_ctx to avoid this.
>
> Fixes: f86dc320a894 ("net/bnxt: fill cfa action in Tx descriptor")
>
> Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
> Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
> Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
>
Patch applied to dpdk-next-net-brcm. Thanks


> ---
>  drivers/net/bnxt/bnxt_txr.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/bnxt/bnxt_txr.c b/drivers/net/bnxt/bnxt_txr.c
> index f588426..c741c71 100644
> --- a/drivers/net/bnxt/bnxt_txr.c
> +++ b/drivers/net/bnxt/bnxt_txr.c
> @@ -132,8 +132,9 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf
> *tx_pkt,
>                                 PKT_TX_TUNNEL_GRE | PKT_TX_TUNNEL_VXLAN |
>                                 PKT_TX_TUNNEL_GENEVE |
> PKT_TX_IEEE1588_TMST |
>                                 PKT_TX_QINQ_PKT) ||
> -            txq->bp->ulp_ctx->cfg_data->tx_cfa_action ||
> -            txq->vfr_tx_cfa_action)
> +            (BNXT_TRUFLOW_EN(txq->bp) &&
> +             (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;
> --
> 2.7.4
>
>
  

Patch

diff --git a/drivers/net/bnxt/bnxt_txr.c b/drivers/net/bnxt/bnxt_txr.c
index f588426..c741c71 100644
--- a/drivers/net/bnxt/bnxt_txr.c
+++ b/drivers/net/bnxt/bnxt_txr.c
@@ -132,8 +132,9 @@  static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
 				PKT_TX_TUNNEL_GRE | PKT_TX_TUNNEL_VXLAN |
 				PKT_TX_TUNNEL_GENEVE | PKT_TX_IEEE1588_TMST |
 				PKT_TX_QINQ_PKT) ||
-	     txq->bp->ulp_ctx->cfg_data->tx_cfa_action ||
-	     txq->vfr_tx_cfa_action)
+	     (BNXT_TRUFLOW_EN(txq->bp) &&
+	      (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;