+static int
+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;
+ 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, "event_mode") == 0) {
+ if (tmp <= MLX5_VDPA_EVENT_MODE_ONLY_INTERRUPT)
+ priv->event_mode = (int)tmp;
+ else
+ DRV_LOG(WARNING, "Invalid event_mode %s.", val);
+ } else if (strcmp(key, "event_us") == 0) {
+ 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);
+ }
+ return 0;
+}
+
+static void
+mlx5_vdpa_config_get(struct rte_devargs *devargs, struct mlx5_vdpa_priv *priv)
+{
+ struct rte_kvargs *kvlist;
+
+ 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;
+ 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);
+ 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);
+}
+