net/mlx5: support imissed counter on Windows
[dpdk.git] / drivers / net / mlx5 / windows / mlx5_os.c
index 5e88453..ac0af0f 100644 (file)
@@ -72,6 +72,22 @@ static struct mlx5_indexed_pool_config icfg[] = {
        },
 };
 
+static void
+mlx5_queue_counter_id_prepare(struct rte_eth_dev *dev)
+{
+       struct mlx5_priv *priv = dev->data->dev_private;
+       void *ctx = priv->sh->cdev->ctx;
+
+       priv->q_counters = mlx5_devx_cmd_queue_counter_alloc(ctx);
+       if (!priv->q_counters) {
+               DRV_LOG(ERR, "Port %d queue counter object cannot be created "
+                       "by DevX - imissed counter will be unavailable",
+                       dev->data->port_id);
+               return;
+       }
+       priv->counter_set_id = priv->q_counters->id;
+}
+
 /**
  * Initialize shared data between primary and secondary process.
  *
@@ -226,7 +242,7 @@ mlx5_os_free_shared_dr(struct mlx5_priv *priv)
  *   Pointer to RQ channel object, which includes the channel fd
  *
  * @param[out] fd
- *   The file descriptor (representing the intetrrupt) used in this channel.
+ *   The file descriptor (representing the interrupt) used in this channel.
  *
  * @return
  *   0 on successfully setting the fd to non-blocking, non-zero otherwise.
@@ -605,7 +621,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
                        goto error;
        }
        /* No supported flow priority number detection. */
-       priv->config.flow_prio = -1;
+       priv->sh->flow_max_priority = -1;
        if (!priv->config.dv_esw_en &&
            priv->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) {
                DRV_LOG(WARNING, "metadata mode %u is not supported "
@@ -626,10 +642,12 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
                mlx5_hrxq_remove_cb, mlx5_hrxq_clone_cb,
                mlx5_hrxq_clone_free_cb);
        /* Query availability of metadata reg_c's. */
-       err = mlx5_flow_discover_mreg_c(eth_dev);
-       if (err < 0) {
-               err = -err;
-               goto error;
+       if (!priv->sh->metadata_regc_check_flag) {
+               err = mlx5_flow_discover_mreg_c(eth_dev);
+               if (err < 0) {
+                       err = -err;
+                       goto error;
+               }
        }
        if (!mlx5_flow_ext_mreg_supported(eth_dev)) {
                DRV_LOG(DEBUG,
@@ -653,6 +671,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
                goto error;
        }
        mlx5_flow_counter_mode_config(eth_dev);
+       mlx5_queue_counter_id_prepare(eth_dev);
        return eth_dev;
 error:
        if (priv) {
@@ -716,7 +735,8 @@ mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh)
  * @param[out] stat
  *   Pointer to read statistic value.
  * @return
- *   0 on success and stat is valud, 1 if failed to read the value
+ *   0 on success and stat is valid, non-zero if failed to read the value
+ *   or counter is not supported.
  *   rte_errno is set.
  *
  */
@@ -724,10 +744,11 @@ int
 mlx5_os_read_dev_stat(struct mlx5_priv *priv, const char *ctr_name,
                      uint64_t *stat)
 {
-       RTE_SET_USED(priv);
-       RTE_SET_USED(ctr_name);
-       RTE_SET_USED(stat);
-       DRV_LOG(WARNING, "%s: is not supported", __func__);
+       if (priv->q_counters != NULL && strcmp(ctr_name, "out_of_buffer") == 0)
+               return mlx5_devx_cmd_queue_counter_query
+                               (priv->q_counters, 0, (uint32_t *)stat);
+       DRV_LOG(WARNING, "%s: is not supported for the %s counter",
+               __func__, ctr_name);
        return -ENOTSUP;
 }