Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Aug 2023 09:17:38 GMT
From:      Wei Hu <whu@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: e4e11c1d07f5 - main - mana: batch ringing RX queue doorbell on receiving packets
Message-ID:  <202308280917.37S9HcuQ049286@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by whu:

URL: https://cgit.FreeBSD.org/src/commit/?id=e4e11c1d07f5d58ff8cf4e07ac8f61eecbbb5417

commit e4e11c1d07f5d58ff8cf4e07ac8f61eecbbb5417
Author:     Wei Hu <whu@FreeBSD.org>
AuthorDate: 2023-08-28 09:15:16 +0000
Commit:     Wei Hu <whu@FreeBSD.org>
CommitDate: 2023-08-28 09:15:16 +0000

    mana: batch ringing RX queue doorbell on receiving packets
    
    It's inefficient to ring the doorbell page every time a WQE is posted to
    the received queue. Excessive MMIO writes result in CPU spending more
    time waiting on LOCK instructions (atomic operations), resulting in
    poor scaling performance.
    
    Move the code for ringing doorbell page to where after we have posted all
    WQEs to the receive queue in mana_poll_rx_cq().
    
    In addition, use the correct WQE count for ringing RQ doorbell.
    The hardware specification specifies that WQE_COUNT should set to 0 for
    the Receive Queue. Although currently the hardware doesn't enforce the
    check, in the future releases it may check on this value.
    
    Tested by:      whu
    MFC after:      1 week
    Sponsored by:   Microsoft
---
 sys/dev/mana/gdma_main.c | 2 +-
 sys/dev/mana/mana_en.c   | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/sys/dev/mana/gdma_main.c b/sys/dev/mana/gdma_main.c
index 2de606d54957..a601873876cb 100644
--- a/sys/dev/mana/gdma_main.c
+++ b/sys/dev/mana/gdma_main.c
@@ -471,7 +471,7 @@ void
 mana_gd_wq_ring_doorbell(struct gdma_context *gc, struct gdma_queue *queue)
 {
 	mana_gd_ring_doorbell(gc, queue->gdma_dev->doorbell, queue->type,
-	    queue->id, queue->head * GDMA_WQE_BU_SIZE, 1);
+	    queue->id, queue->head * GDMA_WQE_BU_SIZE, 0);
 }
 
 void
diff --git a/sys/dev/mana/mana_en.c b/sys/dev/mana/mana_en.c
index 49558cdc97c6..fa49e06e4862 100644
--- a/sys/dev/mana/mana_en.c
+++ b/sys/dev/mana/mana_en.c
@@ -1524,7 +1524,7 @@ mana_post_pkt_rxq(struct mana_rxq *rxq)
 
 	recv_buf_oob = &rxq->rx_oobs[curr_index];
 
-	err = mana_gd_post_and_ring(rxq->gdma_rq, &recv_buf_oob->wqe_req,
+	err = mana_gd_post_work_request(rxq->gdma_rq, &recv_buf_oob->wqe_req,
 	    &recv_buf_oob->wqe_inf);
 	if (err) {
 		mana_err(NULL, "WARNING: rxq %u post pkt err %d\n",
@@ -1757,6 +1757,13 @@ mana_poll_rx_cq(struct mana_cq *cq)
 		mana_process_rx_cqe(cq->rxq, cq, &comp[i]);
 	}
 
+	if (comp_read > 0) {
+		struct gdma_context *gc =
+		    cq->rxq->gdma_rq->gdma_dev->gdma_context;
+
+		mana_gd_wq_ring_doorbell(gc, cq->rxq->gdma_rq);
+	}
+
 	tcp_lro_flush_all(&cq->rxq->lro);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202308280917.37S9HcuQ049286>