From patchwork Fri Oct 27 23:22:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13439312 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1ABB641A8F for ; Fri, 27 Oct 2023 23:23:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="PWJwLGFm" Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7171EC2 for ; Fri, 27 Oct 2023 16:23:52 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-779fb118fe4so183975685a.2 for ; Fri, 27 Oct 2023 16:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1698449031; x=1699053831; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=h1IKuOFcxcdnUxnoTb3yojU0UW/PSUXvaXjLHAHbCSI=; b=PWJwLGFm0HYfZ3AdLJVsbxKUfiMSobdb3IfFRsokQVEK3w1ZvBTI8Si9+xAPTnf7OO yBxfSfFx3HxpKVE79+3EJDRYCy8EkpAy/TiHjdWN5UW71qD/xhry1qG1Skt9rQXLzlMK zbgNe3UyIUZOXr/h18S33IH8iN+3i/h02WUP4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698449031; x=1699053831; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h1IKuOFcxcdnUxnoTb3yojU0UW/PSUXvaXjLHAHbCSI=; b=aLlNvvatvRzr7yQRfe+VpN3RBUHJ/1S1R40z63RquLDo3m4dCvqKoTAAHAtrwDYG8m Osju4kgigRurfXgPvjGDHWD2iYHBr5XehcGLUHsYZQfb0ho+wi6pSKhHrlgrNcAO74Sh LjmuYw+oNXI0zTzjuBV0cRMmjCtJc7ohnauucHc9ln9HoRc/efwOAr4sT+JjXEUHwNSn uuKpAv8M2J/MokHBqRxJztedFA9G0YwYmUyZsMEXjmsQBDoDb3vVye4djWILWRE1BplR +7agY6qKsMxyLucNWVOGQJAGfRiiSc/NJyLhufR91fdW7bjKuS0IvDmxK/7Hoq9xrikW S+Pw== X-Gm-Message-State: AOJu0YwVOFDhIbKUtdBCiFTgnHssx5R5li11gjs77GebNW1upTIHrwpq EzlKDoNdq0YmAMMOlyI7CSNo0g== X-Google-Smtp-Source: AGHT+IGysVMNx2GlxWul2da+qA/qcd3/mpHWteY3GCtjGRR63PMIOfXPFJHMtRYPnenjf0Y73QTR0w== X-Received: by 2002:a05:620a:284d:b0:773:c1a5:148f with SMTP id h13-20020a05620a284d00b00773c1a5148fmr4501955qkp.65.1698449030894; Fri, 27 Oct 2023 16:23:50 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id y27-20020a05620a09db00b007742ad3047asm984169qky.54.2023.10.27.16.23.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Oct 2023 16:23:50 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, gospo@broadcom.com, Somnath Kotur , Pavan Chebbi Subject: [PATCH net-next 13/13] bnxt_en: Optimize xmit_more TX path Date: Fri, 27 Oct 2023 16:22:52 -0700 Message-Id: <20231027232252.36111-14-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231027232252.36111-1-michael.chan@broadcom.com> References: <20231027232252.36111-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Now that we use the cumulative consumer index scheme for TX completion, we don't need to have one TX completion per TX packet in the xmit_more code path. Set the TX_BD_FLAGS_NO_CMPL flag if xmit_more is true. Fallback to one interrupt per packet if the ring is filled beyond bp->tx_wake_thresh. Also, move the wmb() to bnxt_txr_db_kick(). When xmit_more is true, we'll skip the bnxt_txr_db_kick() call and there is no need to call wmb() to sync. the TX BD data. Reviewed-by: Somnath Kotur Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index d1af1d2ff800..e6ac1bd21bb3 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -381,6 +381,8 @@ static u16 bnxt_xmit_get_cfa_action(struct sk_buff *skb) static void bnxt_txr_db_kick(struct bnxt *bp, struct bnxt_tx_ring_info *txr, u16 prod) { + /* Sync BD data before updating doorbell */ + wmb(); bnxt_db_write(bp, &txr->tx_db, prod); txr->kick_pending = 0; } @@ -388,7 +390,7 @@ static void bnxt_txr_db_kick(struct bnxt *bp, struct bnxt_tx_ring_info *txr, static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct bnxt *bp = netdev_priv(dev); - struct tx_bd *txbd; + struct tx_bd *txbd, *txbd0; struct tx_bd_ext *txbd1; struct netdev_queue *txq; int i; @@ -602,6 +604,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) txbd1->tx_bd_cfa_meta = cpu_to_le32(vlan_tag_flags); txbd1->tx_bd_cfa_action = cpu_to_le32(cfa_action << TX_BD_CFA_ACTION_SHIFT); + txbd0 = txbd; for (i = 0; i < last_frag; i++) { skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; @@ -633,16 +636,17 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) skb_tx_timestamp(skb); - /* Sync BD data before updating doorbell */ - wmb(); - prod = NEXT_TX(prod); WRITE_ONCE(txr->tx_prod, prod); - if (!netdev_xmit_more() || netif_xmit_stopped(txq)) + if (!netdev_xmit_more() || netif_xmit_stopped(txq)) { bnxt_txr_db_kick(bp, txr, prod); - else + } else { + if (free_size >= bp->tx_wake_thresh) + txbd0->tx_bd_len_flags_type |= + cpu_to_le32(TX_BD_FLAGS_NO_CMPL); txr->kick_pending = 1; + } tx_done: