From patchwork Mon Nov 20 23:44:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13462289 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="P7EmitlF" Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D8D7C7 for ; Mon, 20 Nov 2023 15:44:54 -0800 (PST) Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-41ea8debcdaso29402881cf.1 for ; Mon, 20 Nov 2023 15:44:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1700523893; x=1701128693; 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=0yyqM9MOXV0F74BMbhpiadlrwI85BPD9MewMelPilU4=; b=P7EmitlFX9UWiMRmFfeuLUzN39dmvdm/tnaP3Y+LWUeuur1Fz8TKid6ldGBVUDKjmL M0hU167mP8/qSv1/IRwBeksTqsUyf3OqkPUAe60lVmbep97FGTnmsZ1KacjsFMcbnL27 pDQANka2blaNraBu734MGLlzhkmdR0YstQGdc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700523893; x=1701128693; 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=0yyqM9MOXV0F74BMbhpiadlrwI85BPD9MewMelPilU4=; b=tw623PkyBI5Z/kj8VGEerQ3aYWjh2B09pB/NcHoerF6ue30UFPxQ8xLwm8bwXkHvSr RKDzBl+VODnN0eA3RT4OHIUCXSXnqx5oBNdGljJU9X9dCb04GbIjhUTMsQm10s2f7JM8 ZKTlflNqVB86Mpeuoyi89X3Hiam5QpugjkAgartJ2xLInWoR2mx3/SuBJoNxz7GHPTEI yKaTwLvK8+bG0yFesREbGRSXyrmiBHLhr/x8PTKo0zLHHnUVqGazJM+3jkCuTTZKiBd/ OXCynEIACB2+cIQQwUlQkkV7gG9zcqFeMsf8/cJZKsnoRD4pbREt3MGGRuw2WpdUvr3o LtiA== X-Gm-Message-State: AOJu0YzWYP/sKjEERZ5HYmpF7rmmJdE21Wwg6I6byn09zxSi/G+cLwEV 8rqFTnLl+3hsUY4OclAafNBFXA== X-Google-Smtp-Source: AGHT+IFT0LRC8wHkW1fL0XMBEYI7VwYL8EDJjfOeOL62Qgj+I7vrLkBhNlWAXc1YVY6A+ZrFX9/EMQ== X-Received: by 2002:ac8:5fce:0:b0:41e:1dff:bed5 with SMTP id k14-20020ac85fce000000b0041e1dffbed5mr12205267qta.37.1700523893280; Mon, 20 Nov 2023 15:44:53 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id i9-20020ac871c9000000b0041803dfb240sm3053384qtp.45.2023.11.20.15.44.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2023 15:44:52 -0800 (PST) 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 12/13] bnxt_en: Modify the NAPI logic for the new P7 chips Date: Mon, 20 Nov 2023 15:44:04 -0800 Message-Id: <20231120234405.194542-13-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231120234405.194542-1-michael.chan@broadcom.com> References: <20231120234405.194542-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 Modify the NAPI logic for the new doorbell mechanism on P7 chips. These changes are compatible with the current P5 chips. In the current logic, bnxt_poll_p5() services 1 or more CQs for each MSIX. Each MSIX has an associated NQ and each NQ has 1 or more associated CQs. If any CQ reaches NAPI budget, we'll stay in polling mode and will unconditionally check and service all CQs until we exit polling. We always re-arm all CQs when we exit polling. To be compatible with the new Toggle bit mechanism in P7 chips, we need to modify the logic so that we service and re-arm the CQ only if we receive an NQE notification for work for that CQ. We add a new had_nqe_notify bit to the cp_ring_info structure and it gets set when we see the NQE notification for that CQ anytime during polling. We'll service and re-arm only the CQs with the had_nqe_notify bits set. Reviewed-by: Somnath Kotur Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 ++++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index b2cf42953130..f968bf12989b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -2854,8 +2854,11 @@ static int __bnxt_poll_cqs(struct bnxt *bp, struct bnxt_napi *bnapi, int budget) for (i = 0; i < cpr->cp_ring_count; i++) { struct bnxt_cp_ring_info *cpr2 = &cpr->cp_ring_arr[i]; - work_done += __bnxt_poll_work(bp, cpr2, budget - work_done); - cpr->has_more_work |= cpr2->has_more_work; + if (cpr2->had_nqe_notify) { + work_done += __bnxt_poll_work(bp, cpr2, + budget - work_done); + cpr->has_more_work |= cpr2->has_more_work; + } } return work_done; } @@ -2876,6 +2879,8 @@ static void __bnxt_poll_cqs_done(struct bnxt *bp, struct bnxt_napi *bnapi, DB_RING_IDX(db, cpr2->cp_raw_cons), db->doorbell); cpr2->had_work_done = 0; + if (dbr_type == DBR_TYPE_CQ_ARMALL) + cpr2->had_nqe_notify = 0; } } __bnxt_poll_work_done(bp, bnapi, budget); @@ -2934,6 +2939,7 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget) idx = BNXT_NQ_HDL_IDX(idx); cpr2 = &cpr->cp_ring_arr[idx]; + cpr2->had_nqe_notify = 1; work_done += __bnxt_poll_work(bp, cpr2, budget - work_done); cpr->has_more_work |= cpr2->has_more_work; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 17e1881c8a27..b287e4a9adff 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1017,6 +1017,8 @@ struct bnxt_cp_ring_info { u8 had_work_done:1; u8 has_more_work:1; + u8 had_nqe_notify:1; + u8 cp_ring_type; u8 cp_idx;