vdpa/mlx5: add hardware queue moderation
[dpdk.git] / drivers / vdpa / mlx5 / mlx5_vdpa.c
index b64f364..0f22a86 100644 (file)
@@ -612,6 +612,7 @@ mlx5_vdpa_args_check_handler(const char *key, const char *val, void *opaque)
 {
        struct mlx5_vdpa_priv *priv = opaque;
        unsigned long tmp;
+       int n_cores = sysconf(_SC_NPROCESSORS_ONLN);
 
        if (strcmp(key, "class") == 0)
                return 0;
@@ -630,6 +631,17 @@ mlx5_vdpa_args_check_handler(const char *key, const char *val, void *opaque)
                priv->event_us = (uint32_t)tmp;
        } else if (strcmp(key, "no_traffic_time") == 0) {
                priv->no_traffic_time_s = (uint32_t)tmp;
+       } else if (strcmp(key, "event_core") == 0) {
+               if (tmp >= (unsigned long)n_cores)
+                       DRV_LOG(WARNING, "Invalid event_core %s.", val);
+               else
+                       priv->event_core = tmp;
+       } else if (strcmp(key, "hw_latency_mode") == 0) {
+               priv->hw_latency_mode = (uint32_t)tmp;
+       } else if (strcmp(key, "hw_max_latency_us") == 0) {
+               priv->hw_max_latency_us = (uint32_t)tmp;
+       } else if (strcmp(key, "hw_max_pending_comp") == 0) {
+               priv->hw_max_pending_comp = (uint32_t)tmp;
        } else {
                DRV_LOG(WARNING, "Invalid key %s.", key);
        }
@@ -641,8 +653,9 @@ mlx5_vdpa_config_get(struct rte_devargs *devargs, struct mlx5_vdpa_priv *priv)
 {
        struct rte_kvargs *kvlist;
 
-       priv->event_mode = MLX5_VDPA_EVENT_MODE_DYNAMIC_TIMER;
+       priv->event_mode = MLX5_VDPA_EVENT_MODE_FIXED_TIMER;
        priv->event_us = 0;
+       priv->event_core = -1;
        priv->no_traffic_time_s = MLX5_VDPA_DEFAULT_NO_TRAFFIC_TIME_S;
        if (devargs == NULL)
                return;
@@ -651,12 +664,9 @@ mlx5_vdpa_config_get(struct rte_devargs *devargs, struct mlx5_vdpa_priv *priv)
                return;
        rte_kvargs_process(kvlist, NULL, mlx5_vdpa_args_check_handler, priv);
        rte_kvargs_free(kvlist);
-       if (!priv->event_us) {
-               if (priv->event_mode == MLX5_VDPA_EVENT_MODE_DYNAMIC_TIMER)
-                       priv->event_us = MLX5_VDPA_DEFAULT_TIMER_STEP_US;
-               else if (priv->event_mode == MLX5_VDPA_EVENT_MODE_FIXED_TIMER)
-                       priv->event_us = MLX5_VDPA_DEFAULT_TIMER_DELAY_US;
-       }
+       if (!priv->event_us &&
+           priv->event_mode == MLX5_VDPA_EVENT_MODE_DYNAMIC_TIMER)
+               priv->event_us = MLX5_VDPA_DEFAULT_TIMER_STEP_US;
        DRV_LOG(DEBUG, "event mode is %d.", priv->event_mode);
        DRV_LOG(DEBUG, "event_us is %u us.", priv->event_us);
        DRV_LOG(DEBUG, "no traffic time is %u s.", priv->no_traffic_time_s);