#include <linux/refcount.h>
 #include <linux/xarray.h>
 #include <linux/if_macvlan.h>
+#include <linux/debugfs.h>
 
 #include "lib/fs_chains.h"
 #include "en/tc_ct.h"
 #define ct_dbg(fmt, args...)\
        netdev_dbg(ct_priv->netdev, "ct_debug: " fmt "\n", ##args)
 
+struct mlx5_tc_ct_debugfs {
+       struct {
+               atomic_t offloaded;
+               atomic_t rx_dropped;
+       } stats;
+
+       struct dentry *root;
+};
+
 struct mlx5_tc_ct_priv {
        struct mlx5_core_dev *dev;
        const struct net_device *netdev;
        struct mlx5_ct_fs *fs;
        struct mlx5_ct_fs_ops *fs_ops;
        spinlock_t ht_lock; /* protects ft entries */
+
+       struct mlx5_tc_ct_debugfs debugfs;
 };
 
 struct mlx5_ct_flow {
 {
        mlx5_tc_ct_entry_del_rule(ct_priv, entry, true);
        mlx5_tc_ct_entry_del_rule(ct_priv, entry, false);
+
+       atomic_dec(&ct_priv->debugfs.stats.offloaded);
 }
 
 static struct flow_action_entry *
        if (err)
                goto err_nat;
 
+       atomic_inc(&ct_priv->debugfs.stats.offloaded);
        return 0;
 
 err_nat:
        return err;
 }
 
+static void
+mlx5_ct_tc_create_dbgfs(struct mlx5_tc_ct_priv *ct_priv)
+{
+       bool is_fdb = ct_priv->ns_type == MLX5_FLOW_NAMESPACE_FDB;
+       struct mlx5_tc_ct_debugfs *ct_dbgfs = &ct_priv->debugfs;
+       char dirname[16] = {};
+
+       if (sscanf(dirname, "ct_%s", is_fdb ? "fdb" : "nic") < 0)
+               return;
+
+       ct_dbgfs->root = debugfs_create_dir(dirname, mlx5_debugfs_get_dev_root(ct_priv->dev));
+       debugfs_create_atomic_t("offloaded", 0400, ct_dbgfs->root,
+                               &ct_dbgfs->stats.offloaded);
+       debugfs_create_atomic_t("rx_dropped", 0400, ct_dbgfs->root,
+                               &ct_dbgfs->stats.rx_dropped);
+}
+
+static void
+mlx5_ct_tc_remove_dbgfs(struct mlx5_tc_ct_priv *ct_priv)
+{
+       debugfs_remove_recursive(ct_priv->debugfs.root);
+}
+
 #define INIT_ERR_PREFIX "tc ct offload init failed"
 
 struct mlx5_tc_ct_priv *
        if (err)
                goto err_init_fs;
 
+       mlx5_ct_tc_create_dbgfs(ct_priv);
        return ct_priv;
 
 err_init_fs:
        if (!ct_priv)
                return;
 
+       mlx5_ct_tc_remove_dbgfs(ct_priv);
        chains = ct_priv->chains;
 
        ct_priv->fs_ops->destroy(ct_priv->fs);
                return true;
 
        if (mapping_find(ct_priv->zone_mapping, zone_restore_id, &zone))
-               return false;
+               goto out_inc_drop;
 
        if (!mlx5_tc_ct_skb_to_tuple(skb, &tuple, zone))
-               return false;
+               goto out_inc_drop;
 
        spin_lock(&ct_priv->ht_lock);
 
        entry = mlx5_tc_ct_entry_get(ct_priv, &tuple);
        if (!entry) {
                spin_unlock(&ct_priv->ht_lock);
-               return false;
+               goto out_inc_drop;
        }
 
        if (IS_ERR(entry)) {
                spin_unlock(&ct_priv->ht_lock);
-               return false;
+               goto out_inc_drop;
        }
        spin_unlock(&ct_priv->ht_lock);
 
        __mlx5_tc_ct_entry_put(entry);
 
        return true;
+
+out_inc_drop:
+       atomic_inc(&ct_priv->debugfs.stats.rx_dropped);
+       return false;
 }