From owner-svn-src-stable-11@freebsd.org Thu Aug 3 13:55:41 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4184ADBE1C4; Thu, 3 Aug 2017 13:55:41 +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 mx1.freebsd.org (Postfix) with ESMTPS id 1B8917D06B; Thu, 3 Aug 2017 13:55:41 +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 v73Dte9W049955; Thu, 3 Aug 2017 13:55:40 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v73DtdDZ049951; Thu, 3 Aug 2017 13:55:39 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201708031355.v73DtdDZ049951@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 3 Aug 2017 13:55:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r321995 - in stable/11/sys/dev/mlx5: . mlx5_core mlx5_en X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/11/sys/dev/mlx5: . mlx5_core mlx5_en X-SVN-Commit-Revision: 321995 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Aug 2017 13:55:41 -0000 Author: hselasky Date: Thu Aug 3 13:55:39 2017 New Revision: 321995 URL: https://svnweb.freebsd.org/changeset/base/321995 Log: MFC r312527: Add runtime support for modifying the SQ and RQ completion event moderation mode. The presence of this feature is indicated through the firmware capabilities. Sponsored by: Mellanox Technologies Modified: stable/11/sys/dev/mlx5/cq.h stable/11/sys/dev/mlx5/mlx5_core/mlx5_cq.c stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mlx5/cq.h ============================================================================== --- stable/11/sys/dev/mlx5/cq.h Thu Aug 3 13:54:46 2017 (r321994) +++ stable/11/sys/dev/mlx5/cq.h Thu Aug 3 13:55:39 2017 (r321995) @@ -88,6 +88,7 @@ enum { MLX5_CQ_MODIFY_PERIOD = 1 << 0, MLX5_CQ_MODIFY_COUNT = 1 << 1, MLX5_CQ_MODIFY_OVERRUN = 1 << 2, + MLX5_CQ_MODIFY_PERIOD_MODE = 1 << 4, }; enum { @@ -165,6 +166,11 @@ int mlx5_core_modify_cq(struct mlx5_core_dev *dev, str int mlx5_core_modify_cq_moderation(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq, u16 cq_period, u16 cq_max_count); +int mlx5_core_modify_cq_moderation_mode(struct mlx5_core_dev *dev, + struct mlx5_core_cq *cq, + u16 cq_period, + u16 cq_max_count, + u8 cq_mode); int mlx5_debug_cq_add(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq); void mlx5_debug_cq_remove(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq); Modified: stable/11/sys/dev/mlx5/mlx5_core/mlx5_cq.c ============================================================================== --- stable/11/sys/dev/mlx5/mlx5_core/mlx5_cq.c Thu Aug 3 13:54:46 2017 (r321994) +++ stable/11/sys/dev/mlx5/mlx5_core/mlx5_cq.c Thu Aug 3 13:55:39 2017 (r321995) @@ -266,6 +266,28 @@ int mlx5_core_modify_cq_moderation(struct mlx5_core_de return mlx5_core_modify_cq(dev, cq, &in, sizeof(in)); } +int mlx5_core_modify_cq_moderation_mode(struct mlx5_core_dev *dev, + struct mlx5_core_cq *cq, + u16 cq_period, + u16 cq_max_count, + u8 cq_mode) +{ + struct mlx5_modify_cq_mbox_in in; + + memset(&in, 0, sizeof(in)); + + in.cqn = cpu_to_be32(cq->cqn); + in.ctx.cq_period = cpu_to_be16(cq_period); + in.ctx.cq_max_count = cpu_to_be16(cq_max_count); + in.ctx.cqe_sz_flags = (cq_mode & 2) >> 1; + in.ctx.st = (cq_mode & 1) << 7; + in.field_select = cpu_to_be32(MLX5_CQ_MODIFY_PERIOD | + MLX5_CQ_MODIFY_COUNT | + MLX5_CQ_MODIFY_PERIOD_MODE); + + return mlx5_core_modify_cq(dev, cq, &in, sizeof(in)); +} + int mlx5_init_cq_table(struct mlx5_core_dev *dev) { struct mlx5_cq_table *table = &dev->priv.cq_table; Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c ============================================================================== --- stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c Thu Aug 3 13:54:46 2017 (r321994) +++ stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c Thu Aug 3 13:55:39 2017 (r321995) @@ -92,6 +92,7 @@ mlx5e_ethtool_handler(SYSCTL_HANDLER_ARGS) { struct mlx5e_priv *priv = arg1; uint64_t value; + int mode_modify; int was_opened; int error; @@ -114,6 +115,7 @@ mlx5e_ethtool_handler(SYSCTL_HANDLER_ARGS) goto done; } was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state); + mode_modify = MLX5_CAP_GEN(priv->mdev, cq_period_mode_modify); switch (MLX5_PARAM_OFFSET(arg[arg2])) { case MLX5_PARAM_OFFSET(rx_coalesce_usecs): @@ -266,7 +268,7 @@ mlx5e_ethtool_handler(SYSCTL_HANDLER_ARGS) case MLX5_PARAM_OFFSET(rx_coalesce_mode): /* network interface must be down */ - if (was_opened) + if (was_opened != 0 && mode_modify == 0) mlx5e_close_locked(priv->ifp); /* import RX coalesce mode */ @@ -276,13 +278,17 @@ mlx5e_ethtool_handler(SYSCTL_HANDLER_ARGS) priv->params_ethtool.rx_coalesce_mode; /* restart network interface, if any */ - if (was_opened) - mlx5e_open_locked(priv->ifp); + if (was_opened != 0) { + if (mode_modify == 0) + mlx5e_open_locked(priv->ifp); + else + error = mlx5e_refresh_channel_params(priv); + } break; case MLX5_PARAM_OFFSET(tx_coalesce_mode): /* network interface must be down */ - if (was_opened) + if (was_opened != 0 && mode_modify == 0) mlx5e_close_locked(priv->ifp); /* import TX coalesce mode */ @@ -292,8 +298,12 @@ mlx5e_ethtool_handler(SYSCTL_HANDLER_ARGS) priv->params_ethtool.tx_coalesce_mode; /* restart network interface, if any */ - if (was_opened) - mlx5e_open_locked(priv->ifp); + if (was_opened != 0) { + if (mode_modify == 0) + mlx5e_open_locked(priv->ifp); + else + error = mlx5e_refresh_channel_params(priv); + } break; case MLX5_PARAM_OFFSET(hw_lro): Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu Aug 3 13:54:46 2017 (r321994) +++ stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Thu Aug 3 13:55:39 2017 (r321995) @@ -1780,6 +1780,25 @@ mlx5e_close_channels(struct mlx5e_priv *priv) static int mlx5e_refresh_sq_params(struct mlx5e_priv *priv, struct mlx5e_sq *sq) { + + if (MLX5_CAP_GEN(priv->mdev, cq_period_mode_modify)) { + uint8_t cq_mode; + + switch (priv->params.tx_cq_moderation_mode) { + case 0: + cq_mode = MLX5_CQ_PERIOD_MODE_START_FROM_EQE; + break; + default: + cq_mode = MLX5_CQ_PERIOD_MODE_START_FROM_CQE; + break; + } + + return (mlx5_core_modify_cq_moderation_mode(priv->mdev, &sq->cq.mcq, + priv->params.tx_cq_moderation_usec, + priv->params.tx_cq_moderation_pkts, + cq_mode)); + } + return (mlx5_core_modify_cq_moderation(priv->mdev, &sq->cq.mcq, priv->params.tx_cq_moderation_usec, priv->params.tx_cq_moderation_pkts)); @@ -1788,6 +1807,28 @@ mlx5e_refresh_sq_params(struct mlx5e_priv *priv, struc static int mlx5e_refresh_rq_params(struct mlx5e_priv *priv, struct mlx5e_rq *rq) { + + if (MLX5_CAP_GEN(priv->mdev, cq_period_mode_modify)) { + uint8_t cq_mode; + int retval; + + switch (priv->params.rx_cq_moderation_mode) { + case 0: + cq_mode = MLX5_CQ_PERIOD_MODE_START_FROM_EQE; + break; + default: + cq_mode = MLX5_CQ_PERIOD_MODE_START_FROM_CQE; + break; + } + + retval = mlx5_core_modify_cq_moderation_mode(priv->mdev, &rq->cq.mcq, + priv->params.rx_cq_moderation_usec, + priv->params.rx_cq_moderation_pkts, + cq_mode); + + return (retval); + } + return (mlx5_core_modify_cq_moderation(priv->mdev, &rq->cq.mcq, priv->params.rx_cq_moderation_usec, priv->params.rx_cq_moderation_pkts));