From patchwork Mon Jul 17 19:35:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: longli@linuxonhyperv.com X-Patchwork-Id: 121571 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1312952vqt; Mon, 17 Jul 2023 12:52:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlFjMI6qhH3/8dFuIGDZJ3Q7hOKNnWiRoOZedLkeLCOvxGbSi6ZNkMUKlgeRfmAQb7W4sOrL X-Received: by 2002:a05:6512:3083:b0:4fb:896d:bd72 with SMTP id z3-20020a056512308300b004fb896dbd72mr11211557lfd.42.1689623566055; Mon, 17 Jul 2023 12:52:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689623566; cv=none; d=google.com; s=arc-20160816; b=CQLFEafYan/8pYbNtwnClG/J+lYIPgLMKwAdyO+HX7FCcMl4SzbTy8MUeUHx4RHLcv tO1OtqpBUksT9vn2oQul15RDl7Iq8vwBtsb1qL6YnvcQ3yijRWe0+69uv6L3cSwgyRCK spql4+KlmRDQkjcfs+OY7TKPWjRFiEpisezqSKPRJAY38FS6P4mD2SZrzlGH2Or9cX4l ALK9GT/nOphQjwv6Y3jaxdYVH1NB8IYMKheZ2HquKRMormJHVMocDnq8W6aYBiKm5VAN iCV43bKGp+PY/WWs0A4OAwrDRgcP+UJ2qLc33kT0pMakVliznW6MybiSnYy5O8oO7ouy IRHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature:dkim-filter; bh=6tfn9MlpjDiql9rVzLqowicC40WOAVLxwr5d3454KNw=; fh=Iw0wWU78t34osG7gAXXzP86UfZDMmqmgfBBsQvZNQuQ=; b=Fs7hy9fb2JMo9cBIAlHZIL/5pRv32GmnA1atABCNnj3gTx1gHknjVLjHByAUB3cZh9 7HyCs7y8YLxTNM+MGdlxa9HLljsroaoJCEpVOQWgfn/21W8XHEGW6K6QUrfKTotzCc7L 4dBVIR/bdbb7+G2ArHOKDs1CickEpBrtqBiepkpSpMYFmz1WGdbqyAgT3oQpkaCxY2Gy QdXjawklB65J76IEUtm9oGOsfvtHiB8L7nkjQjsHEowV2e5axL/3OZWGrepOn94vJyK7 v/VdYmWYRZrBJedjmhjlng7OqllJkVq9djsbUbJIoALKX5S/uL0n9aT5IEnqqUWunkCp Gdpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=ez625pjL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxonhyperv.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e23-20020a50ec97000000b0051d98294f23si64993edr.270.2023.07.17.12.52.22; Mon, 17 Jul 2023 12:52:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=ez625pjL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxonhyperv.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231629AbjGQTf6 (ORCPT + 99 others); Mon, 17 Jul 2023 15:35:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231339AbjGQTfy (ORCPT ); Mon, 17 Jul 2023 15:35:54 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AC45E9D; Mon, 17 Jul 2023 12:35:53 -0700 (PDT) Received: by linux.microsoft.com (Postfix, from userid 1004) id 44AF121C7A00; Mon, 17 Jul 2023 12:35:53 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 44AF121C7A00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1689622553; bh=6tfn9MlpjDiql9rVzLqowicC40WOAVLxwr5d3454KNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ez625pjLMLsth5TvE2UwuLvAepr2qIf6AyBbCE6o+Cm5/dDveTcKFcvNNHOIwSCNq 9aNl62Vk5AtHPirJUKgZZcmg1GLgq5uRxy7eyZoLMu0h9rQAD59F3mXZ8E8avnZ6MA VEUZLIPM2Duep6e5DsNwUwNDU7PoWMoOvccBsIC4= From: longli@linuxonhyperv.com To: "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Leon Romanovsky , Shradha Gupta , Ajay Sharma , Shachar Raindel , Stephen Hemminger , linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-rdma@vger.kernel.org, Long Li Subject: [PATCH net-next v5 1/2] net: mana: Batch ringing RX queue doorbell on receiving packets Date: Mon, 17 Jul 2023 12:35:38 -0700 Message-Id: <1689622539-5334-2-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1689622539-5334-1-git-send-email-longli@linuxonhyperv.com> References: <1689622539-5334-1-git-send-email-longli@linuxonhyperv.com> X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_SPF_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771698720688510509 X-GMAIL-MSGID: 1771698720688510509 From: Long Li 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 during a callback from napi_poll(). With this change, tests showed an improvement from 120G/s to 160G/s on a 200G physical link, with 16 or 32 hardware queues. Tests showed no regression in network latency benchmarks on single connection. Fixes: ca9c54d2d6a5 ("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)") Reviewed-by: Haiyang Zhang Reviewed-by: Dexuan Cui Signed-off-by: Long Li --- Change log: v2: Check for comp_read > 0 as it might be negative on completion error. Set rq.wqe_cnt to 0 according to BNIC spec. v3: Add details in the commit on the reason of performance increase and test numbers. Add details in the commit on why rq.wqe_cnt should be set to 0 according to hardware spec. Add "Reviewed-by" from Haiyang and Dexuan. v4: Split the original patch into two: one for batching doorbell, one for setting the correct wqe count v5: drop Cc: stable and use net-next drivers/net/ethernet/microsoft/mana/mana_en.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index cd4d5ceb9f2d..1d8abe63fcb8 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -1383,8 +1383,8 @@ static void 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, - &recv_buf_oob->wqe_inf); + err = mana_gd_post_work_request(rxq->gdma_rq, &recv_buf_oob->wqe_req, + &recv_buf_oob->wqe_inf); if (WARN_ON_ONCE(err)) return; @@ -1654,6 +1654,12 @@ static void mana_poll_rx_cq(struct mana_cq *cq) mana_process_rx_cqe(rxq, cq, &comp[i]); } + if (comp_read > 0) { + struct gdma_context *gc = rxq->gdma_rq->gdma_dev->gdma_context; + + mana_gd_wq_ring_doorbell(gc, rxq->gdma_rq); + } + if (rxq->xdp_flush) xdp_do_flush(); } From patchwork Mon Jul 17 19:35:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: longli@linuxonhyperv.com X-Patchwork-Id: 121570 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1312587vqt; Mon, 17 Jul 2023 12:51:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlEMZlT1Rd0E82D4TFt/hQhX/aHEBP+NA1afA8DRycTC9u387qOqtxNtn5du58Is41AS8p7v X-Received: by 2002:a05:6512:1190:b0:4fb:9f93:365e with SMTP id g16-20020a056512119000b004fb9f93365emr10330908lfr.41.1689623506256; Mon, 17 Jul 2023 12:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689623506; cv=none; d=google.com; s=arc-20160816; b=V5hnXHKiiKIG5mhuBYbH/tXa1ztpKlonx+yS6rcdz2mlK3hAasw7TfxztqWkDPfEr5 98j9rF8oBtIIbZoe250n3dR8Y2oXPXg+2HEegQWdp023v5FN3v6yu0f9yoQ/CZw39mQK kLhnLg1nlRTnOd2O4AmZSmGJUSjTOSNlMCBSnS1w6rgipguz1SjPInm2QeI+siOtgJ9l ciITKxqfPFVrhgzCdXuFsR1IdNRNyZqE3T/OgFpxBGzMz8tFA3jbZbVipPzcCiUzQ4hg fZmrOgKqhD6ShulBrmV66FCKrBN4BBc8gnOfOrcOgxsqpwtlVQ7HejB4QSOtElwUZ/Bu oA4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature:dkim-filter; bh=XYVYgOirAsauRpIsvXixfB6J0evqIQh9opQ7LMpeBYg=; fh=Iw0wWU78t34osG7gAXXzP86UfZDMmqmgfBBsQvZNQuQ=; b=v4m9CFfH27QNn+rBm4s142h6OgW45YoWWhkJlwVWFJacvS12olhEu4PtdgeqtuoiDh D+0X1RgMcX58gP+Q7Pz3uRxFjJoDg/Xp82qfzK78gJZbsHtabidgfJb41urIevSlY7SH Q2W0O6Qwld0h5f9bZX5W0Pdwqs9Ujj1BGhgdquEOObvgC264dpTDKDVFrR36Y0k0u1ut JttcVyeW03EpXTvUl0xY8sgx9994wRRQEkG1G2ZDg95v+ZLyK/xgP9IFD8JHgcLty074 SWO26wG6/sp/rTrfRB5/KHslwu+uXfeItn8MKhNtbkfQ2GOo9oOH9DrdCWHjSSQQEhvy RGbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=OTGZ63aK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxonhyperv.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p16-20020aa7d310000000b0051dd37fba6asi68374edq.19.2023.07.17.12.51.22; Mon, 17 Jul 2023 12:51:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=OTGZ63aK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxonhyperv.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231639AbjGQTgF (ORCPT + 99 others); Mon, 17 Jul 2023 15:36:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbjGQTfz (ORCPT ); Mon, 17 Jul 2023 15:35:55 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E435ABE; Mon, 17 Jul 2023 12:35:54 -0700 (PDT) Received: by linux.microsoft.com (Postfix, from userid 1004) id 74E7921C7A03; Mon, 17 Jul 2023 12:35:54 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 74E7921C7A03 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1689622554; bh=XYVYgOirAsauRpIsvXixfB6J0evqIQh9opQ7LMpeBYg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OTGZ63aKpVdiObPnWxlrtfW3yuiycFmIC1TMO5NpnDGQWVNEYqaMuBnfdW0yxyWf/ d10Ag5aFp1R8bnomNulbwL9ag3CVAsyx6VuRhD1oDE4ILLKoauQp9RDn5AQ6AedqPy onH5hYPH7JDTMAQv2jf7Q+YevKdEUUFV6G3AQXhQ= From: longli@linuxonhyperv.com To: "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Leon Romanovsky , Shradha Gupta , Ajay Sharma , Shachar Raindel , Stephen Hemminger , linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-rdma@vger.kernel.org, Long Li Subject: [PATCH net-next v5 2/2] net: mana: Use the correct WQE count for ringing RQ doorbell Date: Mon, 17 Jul 2023 12:35:39 -0700 Message-Id: <1689622539-5334-3-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1689622539-5334-1-git-send-email-longli@linuxonhyperv.com> References: <1689622539-5334-1-git-send-email-longli@linuxonhyperv.com> X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_SPF_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771698657746077695 X-GMAIL-MSGID: 1771698657746077695 From: Long Li 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. Fixes: ca9c54d2d6a5 ("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)") Reviewed-by: Haiyang Zhang Reviewed-by: Dexuan Cui Signed-off-by: Long Li --- Change log: v4: Split the original patch into two: one for batching doorbell, one for setting the correct wqe count v5: Drop Cc: stable and use net-next drivers/net/ethernet/microsoft/mana/gdma_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c index 8f3f78b68592..3765d3389a9a 100644 --- a/drivers/net/ethernet/microsoft/mana/gdma_main.c +++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c @@ -300,8 +300,11 @@ static void mana_gd_ring_doorbell(struct gdma_context *gc, u32 db_index, void mana_gd_wq_ring_doorbell(struct gdma_context *gc, struct gdma_queue *queue) { + /* Hardware Spec specifies that software client should set 0 for + * wqe_cnt for Receive Queues. This value is not used in Send Queues. + */ 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 mana_gd_ring_cq(struct gdma_queue *cq, u8 arm_bit)