From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk0-f42.google.com (mail-vk0-f42.google.com [209.85.213.42]) by dpdk.org (Postfix) with ESMTP id CF1DE2906 for ; Thu, 7 Jul 2016 13:33:49 +0200 (CEST) Received: by mail-vk0-f42.google.com with SMTP id f7so765297vkb.3 for ; Thu, 07 Jul 2016 04:33:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to:cc; bh=aBLSIrRN9X/VeyiU0dx1Gf/CXasIkNR62PCfbTavpbw=; b=VJ1LEjxxo/MLrsEe0faEKFN/r9qEDmuWm9DFg36Y5pnzhjXxYzUVnyshp+fhhdC4e2 2bLPmvMKa1CAY2dL3cvcZsg91U0LiMEPRHMvPidg6w0IzXE2x910Szy9RrmGUxDzxO0x Zs6rctvxlAXNv1Q2MJ9JTvwUkzcbMx6uwKwFVdT8ldNkGWw0+CK7xFcXXBTVWWnJnRye NiEid0xMW0l2stPQbbARAfEhSW8/uejdt/NkQDCQgrGN+KUFuhDa/D/fect87f7Lcmz2 9s/yLaVMGN1bev7E2qzbx1WSoqbcQ5i7mlcvc2YRu3qDmvO/nRTN8anTA4nA8iTUD/m6 GEOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=aBLSIrRN9X/VeyiU0dx1Gf/CXasIkNR62PCfbTavpbw=; b=DXeQ8VPRI9f1ZNFgsFtoQnR4z0guB/NLa0CBsO1mpp7RYMKLE1HHoqkKexiHusymoR IIur54rhkkisrNM6dltHJ6hJvNJDHBvt2z9vWlRjMvgA9SijRuMQo4B2PvDGWNh2fNZV aoJIuTJkAVUnUIdJtL77TLe1tZ+yWr2/sXnm5WU2o8/Zc+MDXUZ0aAhOv40pFLbQLvCK 2F7tzxi9XD0j6+E1XT3+Tv/10WR7Xgl4I3hQxhnlTV+lWfZJZNpY9oLSEmtDHN/848PO BnDXP5+22DlwUFdCQZeQ+3DNLSRzZj6s2rSE43kP11ZHuJWl8L/xmWYWW0MTogwImia9 oBaA== X-Gm-Message-State: ALyK8tJYZQPkjMjMpW3KZBI85XuD/6W9LXDVzj6tDsx9Qb6KUfYTIS82vKAhZnxfdNSuULFP1WBCcdiJCAVPSA== X-Received: by 10.31.154.1 with SMTP id c1mr12373785vke.36.1467891229262; Thu, 07 Jul 2016 04:33:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.159.36.54 with HTTP; Thu, 7 Jul 2016 04:33:48 -0700 (PDT) From: =?UTF-8?Q?Jan_M=C4=99dala?= Date: Thu, 7 Jul 2016 13:33:48 +0200 Message-ID: To: dev@dpdk.org Cc: Alexander Matushevsky , =?UTF-8?Q?Jan_M=C4=99dala?= Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [dpdk-dev] [PATCH] 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: Thu, 07 Jul 2016 11:33:50 -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.8.1