From mboxrd@z Thu Jan 1 00:00:00 1970 From: Moti Haimovsky Subject: [PATCH 3/5] net/mlx4: refine setting Tx completion flag Date: Thu, 24 Aug 2017 18:54:08 +0300 Message-ID: <1503590050-196143-4-git-send-email-motih@mellanox.com> References: <1503590050-196143-1-git-send-email-motih@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain Cc: dev@dpdk.org, Moti Haimovsky To: adrien.mazarguil@6wind.com Return-path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0089.outbound.protection.outlook.com [104.47.0.89]) by dpdk.org (Postfix) with ESMTP id 239877D57 for ; Thu, 24 Aug 2017 17:54:31 +0200 (CEST) In-Reply-To: <1503590050-196143-1-git-send-email-motih@mellanox.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" PMD now take into consideration the amount of entries in the TxQ a packet occupies when choosing weather to set the report-completion flag to the chip or not. Signed-off-by: Moti Haimovsky --- drivers/net/mlx4/mlx4_rxtx.c | 30 +++++++++++------------------- drivers/net/mlx4/mlx4_rxtx.h | 2 +- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c index e41ea9e..dae0e47 100644 --- a/drivers/net/mlx4/mlx4_rxtx.c +++ b/drivers/net/mlx4/mlx4_rxtx.c @@ -461,14 +461,16 @@ /* Fill-in date from last to first */ for (i = wr->num_sge - 1; i >= 0; --i) mlx4_set_data_seg(dseg + i, wr->sg_list + i); - /* Handle control info - * - * For raw eth, the SOLICIT flag is used to indicate that - * no icrc should be calculated - */ - srcrb_flags = MLX4_WQE_CTRL_SOLICIT | - ((wr->send_flags & IBV_SEND_SIGNALED) ? - MLX4_WQE_CTRL_CQ_UPDATE : 0); + /* Handle control info */ + /* For raw eth always set the SOLICIT flag */ + /* Request Tx completion. */ + txq->elts_comp_cd -= nr_txbbs; + if (unlikely(txq->elts_comp_cd <= 0)) { + srcrb_flags = MLX4_WQE_CTRL_SOLICIT | MLX4_WQE_CTRL_CQ_UPDATE; + txq->elts_comp_cd = txq->elts_comp_cd_init; + } else { + srcrb_flags = MLX4_WQE_CTRL_SOLICIT; + } fence_size = (wr->send_flags & IBV_SEND_FENCE ? MLX4_WQE_CTRL_FENCE : 0) | ((wqe_real_size / 16) & 0x3f); owner_opcode = MLX4_OPCODE_SEND | @@ -514,13 +516,12 @@ struct ibv_send_wr *wr_bad = NULL; unsigned int elts_head = txq->elts_head; const unsigned int elts_n = txq->elts_n; - unsigned int elts_comp_cd = txq->elts_comp_cd; unsigned int elts_comp = 0; unsigned int i; unsigned int max; int err; - assert(elts_comp_cd != 0); + assert(txq->elts_comp_cd != 0); mlx4_txq_complete(txq); max = (elts_n - (elts_head - txq->elts_tail)); if (max > elts_n) @@ -560,11 +561,6 @@ tmp = next; } while (tmp != NULL); } - /* Request Tx completion. */ - if (unlikely(--elts_comp_cd == 0)) { - elts_comp_cd = txq->elts_comp_cd_init; - send_flags |= IBV_SEND_SIGNALED; - } if (buf->pkt_len <= txq->max_inline) send_flags |= IBV_SEND_INLINE; /* Update element. */ @@ -580,9 +576,6 @@ /* post the pkt for sending */ err = mlx4_post_send(txq, buf, wr, &wr_bad); if (unlikely(err)) { - if (unlikely(wr_bad->send_flags & - IBV_SEND_SIGNALED)) - elts_comp_cd = 1; elt->buf = NULL; goto stop; } @@ -602,7 +595,6 @@ mlx4_send_flush(txq); txq->elts_head = elts_head; txq->elts_comp += elts_comp; - txq->elts_comp_cd = elts_comp_cd; return i; } diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h index 7cae7e2..35e0de7 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -140,7 +140,7 @@ struct txq { unsigned int elts_head; /**< Current index in (*elts)[]. */ unsigned int elts_tail; /**< First element awaiting completion. */ unsigned int elts_comp; /**< Number of pkts waiting for completion. */ - unsigned int elts_comp_cd; /**< Countdown for next completion. */ + int elts_comp_cd; /**< Countdown for next completion. */ unsigned int elts_comp_cd_init; /**< Initial value for countdown. */ struct mlx4_txq_stats stats; /**< Tx queue counters. */ unsigned int socket; /**< CPU socket ID for allocations. */ -- 1.8.3.1