From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C5D7C433FF for ; Wed, 7 Aug 2019 15:10:47 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id AEF6C21BF2 for ; Wed, 7 Aug 2019 15:10:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=6wind.com header.i=@6wind.com header.b="hntc+Ac8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AEF6C21BF2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=6wind.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4B0424D27; Wed, 7 Aug 2019 17:09:58 +0200 (CEST) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by dpdk.org (Postfix) with ESMTP id 096172B9C for ; Wed, 7 Aug 2019 17:09:44 +0200 (CEST) Received: by mail-wr1-f65.google.com with SMTP id p17so91727762wrf.11 for ; Wed, 07 Aug 2019 08:09:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=0GlbaRdccY54BFN5ZohRBC0g+CI7Vg9FEOu0cE4CYKM=; b=hntc+Ac89OfdC90K51CMqtAtdeSvmEV4SVxwl+4QKttnpqlp86x241B9+zW8eOXw2v jH1ZcR+pzk7yBATnGSoUHZxJO5Ai0+lSv4H1aX6BrnBwErIm24gDz3GIBpxb6Y5ykm7t 66hjLnd7yDKRG9f9BLajbDs1XwhR1G/Rxk06x88AhQYyfUcWpAsdhtE7ssQs7qk5Ai0J b+l06rjYk9LegOHlZqrTH5crkYRdHE22Y9eRZEDPI/ba2NOPuV4WgnitXEjd2HtATXYi 4upiruWKWDPLIcAbdLSOg26Ycha4iCtY3aem/CQZxn/39dReR+5s4ZbRwYUnbX1Dv63b N8Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=0GlbaRdccY54BFN5ZohRBC0g+CI7Vg9FEOu0cE4CYKM=; b=QUigdlx+KruX80bpc1BgdrWh1Zs+1mSwRpSB0aFUXZ97MQhixGsNpF9Tu8LJWYazSO er0zVYKTNcGkVmH70raZMS6dcKHgKk12buo19lq4cElThJPomdqAPN4iQNskvpgaVPdN UKH8tVKcZyXm78FwGn1RTW5KwERE2IYs0rIc6OIAULELswI7hJ1orxHOY+6ABGbR+mnR wk9iimVDc1IORIxz9eXp8yO8y5CWjwnc17Q83QI3acdwjtz6H78vFZV+R2xAC2u0QwLn 39EEP+LYe21AfBFRULvJIYHCGt6q+FOuP4Bu1PJIfZQ6rPwMzmoKbiSTK6Bot8KU4ij0 bM/Q== X-Gm-Message-State: APjAAAV0+Y3139JtuOIqn2xerdcYoXVxav1EYXF884AxSYIzRUN0SMEc Kul+8bqjDWDga9KaJajk6Zxh0T4j5Q== X-Google-Smtp-Source: APXvYqxrLR3O3W2/YDo7kSIipKVZilUzEK81xy9ehmGD3um4jzYFFbog2zSAN7CMXQ83AN5qryPV6Q== X-Received: by 2002:adf:e691:: with SMTP id r17mr11687660wrm.67.1565190583362; Wed, 07 Aug 2019 08:09:43 -0700 (PDT) Received: from ascain.dev.6wind.com. (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id r5sm382862wmh.35.2019.08.07.08.09.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Aug 2019 08:09:42 -0700 (PDT) From: Thierry Herbelot To: dev@dpdk.org Cc: Olivier Matz , stable@dpdk.org, Thomas Monjalon Date: Wed, 7 Aug 2019 17:09:15 +0200 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 19.11 V2 06/12] net/i40e: fix Tx descriptor status api X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Olivier Matz The Tx descriptor status api was not behaving as expected. This API is used to inspect the content of the descriptors in the Tx ring to determine the length of the Tx queue. Since the software advances the tail pointer and the hardware advances the head pointer, the Tx queue is located before txq->tx_tail in the ring. Therefore, a call to rte_eth_tx_descriptor_status(..., offset=20) should inspect the 20th descriptor before the tail, not after. As before, we still need to take care about only checking descriptors that have the RS bit. Additionally, we can avoid an access to the ring if offset is greater or equal to nb_tx_desc - nb_tx_free. Fixes: a9dd9af6f38e ("net/i40e: implement descriptor status API") Cc: stable@dpdk.org Signed-off-by: Olivier Matz --- drivers/net/i40e/i40e_rxtx.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c index 692c3bab4b5f..d84a97732f1e 100644 --- a/drivers/net/i40e/i40e_rxtx.c +++ b/drivers/net/i40e/i40e_rxtx.c @@ -2031,22 +2031,39 @@ i40e_dev_tx_descriptor_status(void *tx_queue, uint16_t offset) struct i40e_tx_queue *txq = tx_queue; volatile uint64_t *status; uint64_t mask, expect; - uint32_t desc; + int32_t desc, dd; if (unlikely(offset >= txq->nb_tx_desc)) return -EINVAL; + if (offset >= txq->nb_tx_desc - txq->nb_tx_free) + return RTE_ETH_TX_DESC_DONE; + + desc = txq->tx_tail - offset - 1; + if (desc < 0) + desc += txq->nb_tx_desc; - desc = txq->tx_tail + offset; - /* go to next desc that has the RS bit */ - desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) * - txq->tx_rs_thresh; - if (desc >= txq->nb_tx_desc) { - desc -= txq->nb_tx_desc; - if (desc >= txq->nb_tx_desc) - desc -= txq->nb_tx_desc; + /* offset is too small, no other way than reading PCI reg */ + if (unlikely(offset < txq->tx_rs_thresh)) { + int16_t tx_head, queue_size; + tx_head = I40E_READ_REG(I40E_VSI_TO_HW(txq->vsi), + I40E_QTX_HEAD(txq->reg_idx)); + queue_size = txq->tx_tail - tx_head; + if (queue_size < 0) + queue_size += txq->nb_tx_desc; + return queue_size > offset ? RTE_ETH_TX_DESC_FULL : + RTE_ETH_TX_DESC_DONE; } - status = &txq->tx_ring[desc].cmd_type_offset_bsz; + /* index of the dd bit to look at */ + dd = (desc / txq->tx_rs_thresh + 1) * txq->tx_rs_thresh - 1; + + /* In full featured mode, RS bit is only set in the last descriptor */ + /* of a multisegments packet */ + if (!(txq->offloads == 0 && + txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST)) + dd = txq->sw_ring[dd].last_id; + + status = &txq->tx_ring[dd].cmd_type_offset_bsz; mask = rte_le_to_cpu_64(I40E_TXD_QW1_DTYPE_MASK); expect = rte_cpu_to_le_64( I40E_TX_DESC_DTYPE_DESC_DONE << I40E_TXD_QW1_DTYPE_SHIFT); -- 2.11.0