From patchwork Thu Jun 18 19:11:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 71761 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 09CEFA04F1; Thu, 18 Jun 2020 21:11:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EE5501C07B; Thu, 18 Jun 2020 21:11:31 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 1E7D81C05C for ; Thu, 18 Jun 2020 21:11:29 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from matan@mellanox.com) with SMTP; 18 Jun 2020 22:11:26 +0300 Received: from pegasus25.mtr.labs.mlnx. (pegasus25.mtr.labs.mlnx [10.210.16.10]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 05IJBIZ8005965; Thu, 18 Jun 2020 22:11:26 +0300 From: Matan Azrad To: Maxime Coquelin Cc: dev@dpdk.org Date: Thu, 18 Jun 2020 19:11:16 +0000 Message-Id: <1592507476-442112-4-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1592507476-442112-1-git-send-email-matan@mellanox.com> References: <1592507476-442112-1-git-send-email-matan@mellanox.com> Subject: [dpdk-dev] [PATCH 3/3] vdpa/mlx5: add traffic control device arguments X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add 2 device arguments to conrol traffic modes: 1. Control the CQ polling timer frequency when traffic is on. 2. Control the non-traffic time which moves the timer to be off. Signed-off-by: Matan Azrad --- doc/guides/vdpadevs/mlx5.rst | 17 ++++++++++++++ drivers/vdpa/mlx5/mlx5_vdpa.c | 46 +++++++++++++++++++++++++++++++++++++ drivers/vdpa/mlx5/mlx5_vdpa.h | 1 + drivers/vdpa/mlx5/mlx5_vdpa_event.c | 6 +---- 4 files changed, 65 insertions(+), 5 deletions(-) diff --git a/doc/guides/vdpadevs/mlx5.rst b/doc/guides/vdpadevs/mlx5.rst index dd377af..05f26e0 100644 --- a/doc/guides/vdpadevs/mlx5.rst +++ b/doc/guides/vdpadevs/mlx5.rst @@ -106,8 +106,25 @@ Run-time configuration - **ethtool** operations on related kernel interfaces also affect the PMD. +Driver options +^^^^^^^^^^^^^^ + - ``class`` parameter [string] Select the class of the driver that should probe the device. `vdpa` for the mlx5 vDPA driver. +- ``timer_delay`` parameter [int] + + A nonzero value allows to configure the internal timer delay in micro-seconds. + The internal timer event causes polling of all the CQs, so this number may + affect the performance. + Default value is 500us. + +- ``no_traffic_time`` parameter [int] + + A nonzero value defines the traffic off time, in seconds, that moves the + driver to no-traffic mode. In this mode the timer events are stopped and + interrupts are configured to the device in order to notify traffic for the + driver. + Default value is 2s. diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index 8b0b3b8..9e758b6 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -43,6 +43,8 @@ #define MLX5_VDPA_MAX_RETRIES 20 #define MLX5_VDPA_USEC 1000 +#define MLX5_VDPA_DEFAULT_TIMER_DELAY_US 500u +#define MLX5_VDPA_DEFAULT_NO_TRAFFIC_TIME_S 2LLU TAILQ_HEAD(mlx5_vdpa_privs, mlx5_vdpa_priv) priv_list = TAILQ_HEAD_INITIALIZER(priv_list); @@ -605,6 +607,49 @@ return -rte_errno; } +static int +mlx5_vdpa_args_check_handler(const char *key, const char *val, void *opaque) +{ + struct mlx5_vdpa_priv *priv = opaque; + unsigned long tmp; + + if (strcmp(key, "class") == 0) + return 0; + errno = 0; + tmp = strtoul(val, NULL, 0); + if (errno) { + DRV_LOG(WARNING, "%s: \"%s\" is an invalid integer.", key, val); + return -errno; + } + if (strcmp(key, "timer_delay") == 0) { + priv->timer_delay_us = (uint32_t)tmp; + } else if (strcmp(key, "no_traffic_time") == 0) { + priv->no_traffic_time_s = (uint32_t)tmp; + } else { + DRV_LOG(WARNING, "Invalid key %s.", key); + return -EINVAL; + } + return 0; +} + +static void +mlx5_vdpa_config_get(struct rte_devargs *devargs, struct mlx5_vdpa_priv *priv) +{ + struct rte_kvargs *kvlist; + + priv->timer_delay_us = MLX5_VDPA_DEFAULT_TIMER_DELAY_US; + priv->no_traffic_time_s = MLX5_VDPA_DEFAULT_NO_TRAFFIC_TIME_S; + if (devargs == NULL) + return; + kvlist = rte_kvargs_parse(devargs->args, NULL); + if (kvlist == NULL) + return; + rte_kvargs_process(kvlist, NULL, mlx5_vdpa_args_check_handler, priv); + rte_kvargs_free(kvlist); + DRV_LOG(DEBUG, "timer delay is %u us.", priv->timer_delay_us); + DRV_LOG(DEBUG, "no traffic time is %u s.", priv->no_traffic_time_s); +} + /** * DPDK callback to register a PCI device. * @@ -694,6 +739,7 @@ rte_errno = rte_errno ? rte_errno : EINVAL; goto error; } + mlx5_vdpa_config_get(pci_dev->device.devargs, priv); SLIST_INIT(&priv->mr_list); pthread_mutex_lock(&priv_list_lock); TAILQ_INSERT_TAIL(&priv_list, priv, next); diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.h b/drivers/vdpa/mlx5/mlx5_vdpa.h index ae1dcd8..28ec0be 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.h +++ b/drivers/vdpa/mlx5/mlx5_vdpa.h @@ -110,6 +110,7 @@ struct mlx5_vdpa_priv { pthread_cond_t timer_cond; volatile uint8_t timer_on; uint32_t timer_delay_us; + uint32_t no_traffic_time_s; int id; /* vDPA device id. */ int vid; /* vhost device id. */ struct ibv_context *ctx; /* Device context. */ diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c b/drivers/vdpa/mlx5/mlx5_vdpa_event.c index 25f11fd..06a373a 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c @@ -20,9 +20,6 @@ #include "mlx5_vdpa.h" -#define MLX5_VDPA_DEFAULT_TIMER_DELAY_US 500u -#define MLX5_VDPA_NO_TRAFFIC_TIME_S 2LLU - void mlx5_vdpa_event_qp_global_release(struct mlx5_vdpa_priv *priv) { @@ -286,7 +283,7 @@ if (!total) { /* No traffic ? stop timer and load interrupts. */ if (current_tic - priv->last_traffic_tic >= - rte_get_timer_hz() * MLX5_VDPA_NO_TRAFFIC_TIME_S) { + rte_get_timer_hz() * priv->no_traffic_time_s) { DRV_LOG(DEBUG, "Device %d traffic was stopped.", priv->id); mlx5_vdpa_arm_all_cqs(priv); @@ -358,7 +355,6 @@ pthread_mutex_init(&priv->timer_lock, NULL); pthread_cond_init(&priv->timer_cond, NULL); priv->timer_on = 0; - priv->timer_delay_us = MLX5_VDPA_DEFAULT_TIMER_DELAY_US; ret = pthread_create(&priv->timer_tid, NULL, mlx5_vdpa_poll_handle, (void *)priv); if (ret) {