From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by dpdk.org (Postfix) with ESMTP id 25ABA66DB for ; Fri, 8 Jul 2016 13:12:27 +0200 (CEST) Received: by mail-lf0-f49.google.com with SMTP id l188so27183722lfe.2 for ; Fri, 08 Jul 2016 04:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VR7afOjo6TCcZDQcSj9qQ8S+DjyPE99DXAwJRpgivzw=; b=Rc3g3+pwm9RFhWY2MHjoTFodVWPqH3VzVu8HL1pWw4oRJuw+M7h3md0K4hYqpHoD+Q Tr0G4DQMqpjGUqa3/wMIb4yLhxcMda5ZWvAUuGdJo7iEQwj3KltAn2wKf0G9+IIXKZz5 DLFS1RSxzYyUq+1uu1w1niTZZx5ZB8noYcBmmomDTFqWiD+wb/uofedkOU5iIBPgU0VN r/x0LmqYY0z04pqjGooLD5FitVcWqDRQXh25NT07bptu8AH8PujBfSRj1jA398l8XoVl iYTf2EVTJbAIEMHgxTOpZCKG0gCa+WDaUJ/LX7xGs06+IXYhJRmFEY3DVXP68G4M0gas ee4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VR7afOjo6TCcZDQcSj9qQ8S+DjyPE99DXAwJRpgivzw=; b=i89zri+KgNKZ9dsEMYimkI0GvBuABTPgIx6/cZB2V35zQxrFKQF/TRwspgh/qruZKw CtIno8A1GL7AWcBORZSJp1zP6lJrVVMFiIhNqJsZ1E3pmaztVlMF7ld9aCDcRO/wTMJ5 6LGP8VvSMZldzoP9n1Rj15G5Hqls5JoE+YJkowR+PF5F+DympItFSj/yNTvSxDdO2smM SfBQ6bZ6RIU+BrhT8Bfm8FyaK0bGEG/Ky4X+CweaWuDOfq/KTJULkljBxzY2VqTckO/u n2uaXEYlhdQcIu1J3GAXpntbrnhjS9Bv/Bx9Sa71Mzd0NdSovrXnRI0Bx9Ox0+zmuDl3 7H1A== X-Gm-Message-State: ALyK8tIqtIZmNYvEerjyHq/fNan4+b1POOywKXcArvbyPgg6wXJmF1Mt4TxBZFHWa3d+bA== X-Received: by 10.25.141.75 with SMTP id p72mr1150100lfd.86.1467976346830; Fri, 08 Jul 2016 04:12:26 -0700 (PDT) Received: from jan-desktop.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id 18sm8382815ljf.7.2016.07.08.04.12.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jul 2016 04:12:26 -0700 (PDT) From: Jan Medala To: dev@dpdk.org Cc: thomas.monjalon@6wind.com, Jan Medala , Alexander Matushevsky Date: Fri, 8 Jul 2016 13:11:30 +0200 Message-Id: <20160708111130.28056-2-jan@semihalf.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160708111130.28056-1-jan@semihalf.com> References: <20160708111130.28056-1-jan@semihalf.com> Subject: [dpdk-dev] [PATCH v2] ena: fix doorbell submission when not needed X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2016 11:12:27 -0000 Avoid submitting doorbell when: * no packets have been submitted to TX * no free resources have been submitted while RX Sending doorbell without actual work to be performed by device violates ENA specification and can lead to unpredictable behavior. Fixes: 1173fca25af9 ("ena: add polling-mode driver") Signed-off-by: Alexander Matushevsky Signed-off-by: Jan Medala --- drivers/net/ena/ena_ethdev.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index 702289b..d68e7ec 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -920,10 +920,14 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count) next_to_use = ENA_RX_RING_IDX_NEXT(next_to_use, ring_size); } - rte_wmb(); - rxq->next_to_use = next_to_use; - /* let HW know that it can fill buffers with data */ - ena_com_write_sq_doorbell(rxq->ena_com_io_sq); + /* When we submitted free recources to device... */ + if (i > 0) { + /* ...let HW know that it can fill buffers with data */ + rte_wmb(); + ena_com_write_sq_doorbell(rxq->ena_com_io_sq); + + rxq->next_to_use = next_to_use; + } return i; } @@ -1316,7 +1320,7 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, struct ena_tx_buffer *tx_info; struct ena_com_buf *ebuf; uint16_t rc, req_id, total_tx_descs = 0; - int sent_idx = 0; + uint16_t sent_idx = 0; int nb_hw_desc; /* Check adapter state */ @@ -1395,9 +1399,14 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, next_to_use = ENA_TX_RING_IDX_NEXT(next_to_use, ring_size); } - /* Let HW do it's best :-) */ - rte_wmb(); - ena_com_write_sq_doorbell(tx_ring->ena_com_io_sq); + /* If there are ready packets to be xmitted... */ + if (sent_idx > 0) { + /* ...let HW do its best :-) */ + rte_wmb(); + ena_com_write_sq_doorbell(tx_ring->ena_com_io_sq); + + tx_ring->next_to_use = next_to_use; + } /* Clear complete packets */ while (ena_com_tx_comp_req_id_get(tx_ring->ena_com_io_cq, &req_id) >= 0) { @@ -1420,9 +1429,11 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, break; } - /* acknowledge completion of sent packets */ - ena_com_comp_ack(tx_ring->ena_com_io_sq, total_tx_descs); - tx_ring->next_to_use = next_to_use; + if (total_tx_descs > 0) { + /* acknowledge completion of sent packets */ + ena_com_comp_ack(tx_ring->ena_com_io_sq, total_tx_descs); + } + return sent_idx; } -- 2.9.0