From patchwork Fri Dec 1 22:39:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13476554 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="ZWEDuooO" Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFB27D67 for ; Fri, 1 Dec 2023 14:39:55 -0800 (PST) Received: by mail-qt1-x82b.google.com with SMTP id d75a77b69052e-423c28db22eso31312141cf.1 for ; Fri, 01 Dec 2023 14:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1701470395; x=1702075195; 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=QBK43eNMRoJ0VYm+mq0tfngczeToPBDiWPoCLfYrtL0=; b=ZWEDuooO8x5CS/vhnUkJeA7HyEYFc7oUYd81c6hbzJCMDkW91LsqifkHiY0N84MAzL BMomIJ3X1bP0d9S2Wfw7KmL4LK3auCwxJJAxc8qHNfvBETcohcRR3YXxo9jU676Bxxa5 RIf2rDKNYl2KTjEUswhUNWgnnKyCC4APiuqas= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701470395; x=1702075195; 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=QBK43eNMRoJ0VYm+mq0tfngczeToPBDiWPoCLfYrtL0=; b=ERb9FjgwDSkl78IzShkvN3tZQvP5QHVwsyHBR+XEsI/behu351FgxA8swTY5fpdl/i X9WsuKMMEOmRC/2zgxROrX4vQy8rA3wQAzZThBFRnt6nGKTh/8DA7AhJdKyzn7du8X6J ycyJZUrM5haIsP0Erc3q//Cn2Fd/byaefTDfA20atIvyYvnfzDiFNare/C+3WCCUJwBJ Ueu7rze7iNwhICiDSflRo+sXGRPN3yXvimo27UGIfrl0DUE8PYQ5Jmlf2h1DCwoSKa/b ANZtGB74itWgk3iG6KoDFt6CbL0nXjg3GWH93KfB8Tt7jp8VYHDSrelri/9lpIKf6E3N q5Mg== X-Gm-Message-State: AOJu0Yxkqgr7gjZIjw+3C5SO36lSKTR+cQi7PnhfLf1xUvzeh1CvNYyl GN/IkawaMlA891PozIp6JY2v0ia5VK5YF3qE5M0= X-Google-Smtp-Source: AGHT+IGVYp9CWfAzaWvk/LobAQYXV0x9H9glxDH9+I+xshtoHaJbogrHRQ/VQOICMhbie5siLlrMVA== X-Received: by 2002:a05:622a:451:b0:425:4042:f45f with SMTP id o17-20020a05622a045100b004254042f45fmr306525qtx.67.1701470394673; Fri, 01 Dec 2023 14:39:54 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id i14-20020ac8488e000000b004199c98f87dsm1878715qtq.74.2023.12.01.14.39.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Dec 2023 14:39:54 -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 Subject: [PATCH net-next 05/15] bnxt_en: Implement the new toggle bit doorbell mechanism on P7 chips Date: Fri, 1 Dec 2023 14:39:14 -0800 Message-Id: <20231201223924.26955-6-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231201223924.26955-1-michael.chan@broadcom.com> References: <20231201223924.26955-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 The new chip family passes the Toggle bits to the driver in the NQE notification. The driver now stores this value and sends it back to hardware when it re-arms the RX and TX CQs. Together with the earlier patch that guarantees the driver will only re-arm the CQ at the end of NAPI polling if it has seen a new NQE, this method allows the hardware to detect any dropped doorbells. Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 17 +++++++++++++---- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index a17de1aceff4..d4da55e01b2c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -2880,13 +2880,18 @@ static void __bnxt_poll_cqs_done(struct bnxt *bp, struct bnxt_napi *bnapi, struct bnxt_db_info *db; if (cpr2->had_work_done) { + u32 tgl = 0; + + if (dbr_type == DBR_TYPE_CQ_ARMALL) { + cpr2->had_nqe_notify = 0; + tgl = cpr2->toggle; + } db = &cpr2->cp_db; - bnxt_writeq(bp, db->db_key64 | dbr_type | + bnxt_writeq(bp, + db->db_key64 | dbr_type | DB_TOGGLE(tgl) | 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); @@ -2912,6 +2917,8 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget) work_done = __bnxt_poll_cqs(bp, bnapi, budget); } while (1) { + u16 type; + cons = RING_CMP(raw_cons); nqcmp = &cpr->nq_desc_ring[CP_RING(cons)][CP_IDX(cons)]; @@ -2933,7 +2940,8 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget) */ dma_rmb(); - if (nqcmp->type == cpu_to_le16(NQ_CN_TYPE_CQ_NOTIFICATION)) { + type = le16_to_cpu(nqcmp->type); + if (NQE_CN_TYPE(type) == NQ_CN_TYPE_CQ_NOTIFICATION) { u32 idx = le32_to_cpu(nqcmp->cq_handle_low); u32 cq_type = BNXT_NQ_HDL_TYPE(idx); struct bnxt_cp_ring_info *cpr2; @@ -2946,6 +2954,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; + cpr2->toggle = NQE_CN_TOGGLE(type); 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 6d96f66dc8c0..79b4deb45cfb 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1038,6 +1038,7 @@ struct bnxt_cp_ring_info { u8 had_work_done:1; u8 has_more_work:1; u8 had_nqe_notify:1; + u8 toggle; u8 cp_ring_type; u8 cp_idx;