From owner-dev-commits-src-branches@freebsd.org Mon Jul 26 16:13:09 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8D81466EFBA; Mon, 26 Jul 2021 16:13:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GYQ2F2nP9z3pL2; Mon, 26 Jul 2021 16:13:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 427BA19E49; Mon, 26 Jul 2021 16:13:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 16QGD9HW005059; Mon, 26 Jul 2021 16:13:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 16QGD9Qw005058; Mon, 26 Jul 2021 16:13:09 GMT (envelope-from git) Date: Mon, 26 Jul 2021 16:13:09 GMT Message-Id: <202107261613.16QGD9Qw005058@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: 6b49b46f2692 - stable/13 - mlx5en: Add more error checks in the transmit path. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6b49b46f2692fa7505b133276d1c878bb6fd5607 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jul 2021 16:13:09 -0000 The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=6b49b46f2692fa7505b133276d1c878bb6fd5607 commit 6b49b46f2692fa7505b133276d1c878bb6fd5607 Author: Hans Petter Selasky AuthorDate: 2021-06-16 13:01:29 +0000 Commit: Hans Petter Selasky CommitDate: 2021-07-26 16:04:28 +0000 mlx5en: Add more error checks in the transmit path. - Upon error more completion events than requested may be generated, particularly when using the completion event factor feature. - Count number of event errors in the transmit path. Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking (cherry picked from commit 4f4739a77b0e69dae57fd1687926d6e48a698fe4) --- sys/dev/mlx5/device.h | 5 +++++ sys/dev/mlx5/mlx5_en/en.h | 1 + sys/dev/mlx5/mlx5_en/mlx5_en_tx.c | 26 ++++++++++++++++++++++---- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/sys/dev/mlx5/device.h b/sys/dev/mlx5/device.h index 64d4ed87d58f..e59fb6771d83 100644 --- a/sys/dev/mlx5/device.h +++ b/sys/dev/mlx5/device.h @@ -692,6 +692,11 @@ struct mlx5_cqe64 { #define MLX5_CQE_TSTMP_PTP (1ULL << 63) +static inline u8 get_cqe_opcode(struct mlx5_cqe64 *cqe) +{ + return (cqe->op_own >> 4); +} + static inline bool get_cqe_lro_timestamp_valid(struct mlx5_cqe64 *cqe) { return (cqe->lro_tcppsh_abort_dupack >> 7) & 1; diff --git a/sys/dev/mlx5/mlx5_en/en.h b/sys/dev/mlx5/mlx5_en/en.h index e4b66bea8f60..b249a82d30ef 100644 --- a/sys/dev/mlx5/mlx5_en/en.h +++ b/sys/dev/mlx5/mlx5_en/en.h @@ -627,6 +627,7 @@ struct mlx5e_rq_stats { m(+1, u64, defragged, "defragged", "Transmitted packets") \ m(+1, u64, dropped, "dropped", "Transmitted packets") \ m(+1, u64, enobuf, "enobuf", "Transmitted packets") \ + m(+1, u64, cqe_err, "cqe_err", "Transmit CQE errors") \ m(+1, u64, nop, "nop", "Transmitted packets") #define MLX5E_SQ_STATS_NUM (0 MLX5E_SQ_STATS(MLX5E_STATS_COUNT)) diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c index 0e8e5f46d032..e85522bdfad7 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c @@ -1037,6 +1037,9 @@ mlx5e_poll_tx_cq(struct mlx5e_sq *sq, int budget) while (budget > 0) { struct mlx5_cqe64 *cqe; struct mbuf *mb; + bool match; + u16 sqcc_this; + u16 delta; u16 x; u16 ci; @@ -1046,11 +1049,28 @@ mlx5e_poll_tx_cq(struct mlx5e_sq *sq, int budget) mlx5_cqwq_pop(&sq->cq.wq); + /* check if the completion event indicates an error */ + if (unlikely(get_cqe_opcode(cqe) != MLX5_CQE_REQ)) + sq->stats.cqe_err++; + + /* setup local variables */ + sqcc_this = be16toh(cqe->wqe_counter); + match = false; + /* update budget according to the event factor */ budget -= sq->cev_factor; - for (x = 0; x != sq->cev_factor; x++) { + for (x = 0;; x++) { + if (unlikely(match != false)) { + break; + } else if (unlikely(x == sq->cev_factor)) { + /* WQE counter match not found */ + sq->stats.cqe_err++; + break; + } ci = sqcc & sq->wq.sz_m1; + delta = sqcc_this - sqcc; + match = (delta < sq->mbuf[ci].num_wqebbs); mb = sq->mbuf[ci].mbuf; sq->mbuf[ci].mbuf = NULL; @@ -1060,10 +1080,8 @@ mlx5e_poll_tx_cq(struct mlx5e_sq *sq, int budget) } if (mb == NULL) { - if (sq->mbuf[ci].num_bytes == 0) { - /* NOP */ + if (unlikely(sq->mbuf[ci].num_bytes == 0)) sq->stats.nop++; - } } else { bus_dmamap_sync(sq->dma_tag, sq->mbuf[ci].dma_map, BUS_DMASYNC_POSTWRITE);