From owner-svn-src-stable@freebsd.org Thu May 16 16:23:59 2019 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 62311159D481; Thu, 16 May 2019 16:23:59 +0000 (UTC) (envelope-from hselasky@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 08BB0893E0; Thu, 16 May 2019 16:23:59 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D53B323565; Thu, 16 May 2019 16:23:58 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4GGNwoi069931; Thu, 16 May 2019 16:23:58 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4GGNwHT069928; Thu, 16 May 2019 16:23:58 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201905161623.x4GGNwHT069928@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 16 May 2019 16:23:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r347761 - stable/12/sys/dev/mlx5/mlx5_en X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/12/sys/dev/mlx5/mlx5_en X-SVN-Commit-Revision: 347761 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 08BB0893E0 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 May 2019 16:23:59 -0000 Author: hselasky Date: Thu May 16 16:23:58 2019 New Revision: 347761 URL: https://svnweb.freebsd.org/changeset/base/347761 Log: MFC r347296: Correct check for the calibration generation in mlx5en(4). If generation is cleared due to hardware clock failure, check for it before the divisor is used. Actually clear generation when failure occurs. While there, stop doing the calculations inside the generation loop. Since all members of mlx5e_clbr_point are used for calculations, get the local copy of the structure and use it after generation stabilized. Submitted by: kib@ Sponsored by: Mellanox Technologies Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu May 16 16:21:32 2019 (r347760) +++ stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu May 16 16:23:58 2019 (r347761) @@ -833,11 +833,15 @@ mlx5e_calibration_callout(void *arg) next->clbr_hw_prev = curr->clbr_hw_curr; next->clbr_hw_curr = mlx5e_hw_clock(priv); - if (((next->clbr_hw_curr - curr->clbr_hw_prev) >> MLX5E_TSTMP_PREC) == + if (((next->clbr_hw_curr - curr->clbr_hw_curr) >> MLX5E_TSTMP_PREC) == 0) { - if_printf(priv->ifp, "HW failed tstmp frozen %#jx %#jx," - "disabling\n", next->clbr_hw_curr, curr->clbr_hw_prev); - priv->clbr_done = 0; + if (priv->clbr_done != 0) { + if_printf(priv->ifp, "HW failed tstmp frozen %#jx %#jx," + "disabling\n", + next->clbr_hw_curr, curr->clbr_hw_prev); + priv->clbr_done = 0; + } + atomic_store_rel_int(&curr->clbr_gen, 0); return; } Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c ============================================================================== --- stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c Thu May 16 16:21:32 2019 (r347760) +++ stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c Thu May 16 16:23:58 2019 (r347761) @@ -222,28 +222,31 @@ mlx5e_lro_update_hdr(struct mbuf *mb, struct mlx5_cqe6 static uint64_t mlx5e_mbuf_tstmp(struct mlx5e_priv *priv, uint64_t hw_tstmp) { - struct mlx5e_clbr_point *cp; + struct mlx5e_clbr_point *cp, dcp; uint64_t a1, a2, res; u_int gen; do { cp = &priv->clbr_points[priv->clbr_curr]; gen = atomic_load_acq_int(&cp->clbr_gen); - a1 = (hw_tstmp - cp->clbr_hw_prev) >> MLX5E_TSTMP_PREC; - a2 = (cp->base_curr - cp->base_prev) >> MLX5E_TSTMP_PREC; - res = (a1 * a2) << MLX5E_TSTMP_PREC; + if (gen == 0) + return (0); + dcp = *cp; + atomic_thread_fence_acq(); + } while (gen != cp->clbr_gen); - /* - * Divisor cannot be zero because calibration callback - * checks for the condition and disables timestamping - * if clock halted. - */ - res /= (cp->clbr_hw_curr - cp->clbr_hw_prev) >> - MLX5E_TSTMP_PREC; + a1 = (hw_tstmp - dcp.clbr_hw_prev) >> MLX5E_TSTMP_PREC; + a2 = (dcp.base_curr - dcp.base_prev) >> MLX5E_TSTMP_PREC; + res = (a1 * a2) << MLX5E_TSTMP_PREC; - res += cp->base_prev; - atomic_thread_fence_acq(); - } while (gen == 0 || gen != cp->clbr_gen); + /* + * Divisor cannot be zero because calibration callback + * checks for the condition and disables timestamping + * if clock halted. + */ + res /= (dcp.clbr_hw_curr - dcp.clbr_hw_prev) >> MLX5E_TSTMP_PREC; + + res += dcp.base_prev; return (res); }