Move the debugfs entry pointers under priv to their own struct.
Add get function for device debugfs root.
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
 
        dev->port[port_num].dbg_cc_params = dbg_cc_params;
 
-       dbg_cc_params->root = debugfs_create_dir("cc_params",
-                                                mdev->priv.dbg_root);
+       dbg_cc_params->root = debugfs_create_dir("cc_params", mlx5_debugfs_get_dev_root(mdev));
 
        for (i = 0; i < MLX5_IB_DBG_CC_MAX; i++) {
                dbg_cc_params->params[i].offset = i;
 
        if (!mlx5_debugfs_root)
                return 0;
 
-       root = debugfs_create_dir("delay_drop", dev->mdev->priv.dbg_root);
+       root = debugfs_create_dir("delay_drop", mlx5_debugfs_get_dev_root(dev->mdev));
        dev->delay_drop.dir_debugfs = root;
 
        debugfs_create_atomic_t("num_timeout_events", 0400, root,
 
        if (!mlx5_debugfs_root || dev->is_rep)
                return;
 
-       cache->root = debugfs_create_dir("mr_cache", dev->mdev->priv.dbg_root);
+       cache->root = debugfs_create_dir("mr_cache", mlx5_debugfs_get_dev_root(dev->mdev));
 
        for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) {
                ent = &cache->ent[i];
 
 {
        struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
 
-       dbg->dbg_root = debugfs_create_dir("cmd", dev->priv.dbg_root);
+       dbg->dbg_root = debugfs_create_dir("cmd", mlx5_debugfs_get_dev_root(dev));
 
        debugfs_create_file("in", 0400, dbg->dbg_root, dev, &dfops);
        debugfs_create_file("out", 0200, dbg->dbg_root, dev, &dfops);
 
        debugfs_remove(mlx5_debugfs_root);
 }
 
+struct dentry *mlx5_debugfs_get_dev_root(struct mlx5_core_dev *dev)
+{
+       return dev->priv.dbg.dbg_root;
+}
+EXPORT_SYMBOL(mlx5_debugfs_get_dev_root);
+
 void mlx5_qp_debugfs_init(struct mlx5_core_dev *dev)
 {
-       dev->priv.qp_debugfs = debugfs_create_dir("QPs",  dev->priv.dbg_root);
+       dev->priv.dbg.qp_debugfs = debugfs_create_dir("QPs", dev->priv.dbg.dbg_root);
 }
 EXPORT_SYMBOL(mlx5_qp_debugfs_init);
 
 void mlx5_qp_debugfs_cleanup(struct mlx5_core_dev *dev)
 {
-       debugfs_remove_recursive(dev->priv.qp_debugfs);
+       debugfs_remove_recursive(dev->priv.dbg.qp_debugfs);
 }
 EXPORT_SYMBOL(mlx5_qp_debugfs_cleanup);
 
 void mlx5_eq_debugfs_init(struct mlx5_core_dev *dev)
 {
-       dev->priv.eq_debugfs = debugfs_create_dir("EQs",  dev->priv.dbg_root);
+       dev->priv.dbg.eq_debugfs = debugfs_create_dir("EQs", dev->priv.dbg.dbg_root);
 }
 
 void mlx5_eq_debugfs_cleanup(struct mlx5_core_dev *dev)
 {
-       debugfs_remove_recursive(dev->priv.eq_debugfs);
+       debugfs_remove_recursive(dev->priv.dbg.eq_debugfs);
 }
 
 static ssize_t average_read(struct file *filp, char __user *buf, size_t count,
        const char *namep;
        int i;
 
-       cmd = &dev->priv.cmdif_debugfs;
-       *cmd = debugfs_create_dir("commands", dev->priv.dbg_root);
+       cmd = &dev->priv.dbg.cmdif_debugfs;
+       *cmd = debugfs_create_dir("commands", dev->priv.dbg.dbg_root);
 
        for (i = 0; i < MLX5_CMD_OP_MAX; i++) {
                stats = &dev->cmd.stats[i];
 
 void mlx5_cmdif_debugfs_cleanup(struct mlx5_core_dev *dev)
 {
-       debugfs_remove_recursive(dev->priv.cmdif_debugfs);
+       debugfs_remove_recursive(dev->priv.dbg.cmdif_debugfs);
 }
 
 void mlx5_cq_debugfs_init(struct mlx5_core_dev *dev)
 {
-       dev->priv.cq_debugfs = debugfs_create_dir("CQs",  dev->priv.dbg_root);
+       dev->priv.dbg.cq_debugfs = debugfs_create_dir("CQs", dev->priv.dbg.dbg_root);
 }
 
 void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev)
 {
-       debugfs_remove_recursive(dev->priv.cq_debugfs);
+       debugfs_remove_recursive(dev->priv.dbg.cq_debugfs);
 }
 
 static u64 qp_read_field(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp,
        if (!mlx5_debugfs_root)
                return 0;
 
-       err = add_res_tree(dev, MLX5_DBG_RSC_QP, dev->priv.qp_debugfs,
+       err = add_res_tree(dev, MLX5_DBG_RSC_QP, dev->priv.dbg.qp_debugfs,
                           &qp->dbg, qp->qpn, qp_fields,
                           ARRAY_SIZE(qp_fields), qp);
        if (err)
        if (!mlx5_debugfs_root)
                return 0;
 
-       err = add_res_tree(dev, MLX5_DBG_RSC_EQ, dev->priv.eq_debugfs,
+       err = add_res_tree(dev, MLX5_DBG_RSC_EQ, dev->priv.dbg.eq_debugfs,
                           &eq->dbg, eq->eqn, eq_fields,
                           ARRAY_SIZE(eq_fields), eq);
        if (err)
        if (!mlx5_debugfs_root)
                return 0;
 
-       err = add_res_tree(dev, MLX5_DBG_RSC_CQ, dev->priv.cq_debugfs,
+       err = add_res_tree(dev, MLX5_DBG_RSC_CQ, dev->priv.dbg.cq_debugfs,
                           &cq->dbg, cq->cqn, cq_fields,
                           ARRAY_SIZE(cq_fields), cq);
        if (err)
 
        INIT_LIST_HEAD(&priv->pgdir_list);
 
        priv->numa_node = dev_to_node(mlx5_core_dma_dev(dev));
-       priv->dbg_root = debugfs_create_dir(dev_name(dev->device),
-                                           mlx5_debugfs_root);
+       priv->dbg.dbg_root = debugfs_create_dir(dev_name(dev->device),
+                                               mlx5_debugfs_root);
        INIT_LIST_HEAD(&priv->traps);
 
        err = mlx5_tout_init(dev);
 err_health_init:
        mlx5_tout_cleanup(dev);
 err_timeout_init:
-       debugfs_remove(dev->priv.dbg_root);
+       debugfs_remove(dev->priv.dbg.dbg_root);
        mutex_destroy(&priv->pgdir_mutex);
        mutex_destroy(&priv->alloc_mutex);
        mutex_destroy(&priv->bfregs.wc_head.lock);
        mlx5_pagealloc_cleanup(dev);
        mlx5_health_cleanup(dev);
        mlx5_tout_cleanup(dev);
-       debugfs_remove_recursive(dev->priv.dbg_root);
+       debugfs_remove_recursive(dev->priv.dbg.dbg_root);
        mutex_destroy(&priv->pgdir_mutex);
        mutex_destroy(&priv->alloc_mutex);
        mutex_destroy(&priv->bfregs.wc_head.lock);
 
        }
 
        dmn->dump_info.steering_debugfs =
-               debugfs_create_dir("steering", dev->priv.dbg_root);
+               debugfs_create_dir("steering", mlx5_debugfs_get_dev_root(dev));
        dmn->dump_info.fdb_debugfs =
                debugfs_create_dir("fdb", dmn->dump_info.steering_debugfs);
 
 
        int idx;
 };
 
+struct mlx5_debugfs_entries {
+       struct dentry *dbg_root;
+       struct dentry *qp_debugfs;
+       struct dentry *eq_debugfs;
+       struct dentry *cq_debugfs;
+       struct dentry *cmdif_debugfs;
+};
+
 struct mlx5_ft_pool;
 struct mlx5_priv {
        /* IRQ table valid only for real pci devices PF or VF */
        struct mlx5_core_health health;
        struct list_head        traps;
 
-       /* start: qp staff */
-       struct dentry          *qp_debugfs;
-       struct dentry          *eq_debugfs;
-       struct dentry          *cq_debugfs;
-       struct dentry          *cmdif_debugfs;
-       /* end: qp staff */
+       struct mlx5_debugfs_entries dbg;
 
        /* start: alloc staff */
        /* protect buffer allocation according to numa node */
        struct mutex            pgdir_mutex;
        struct list_head        pgdir_list;
        /* end: alloc staff */
-       struct dentry          *dbg_root;
 
        struct list_head        ctx_list;
        spinlock_t              ctx_lock;
 int mlx5_core_attach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn);
 int mlx5_core_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn);
 
+struct dentry *mlx5_debugfs_get_dev_root(struct mlx5_core_dev *dev);
 void mlx5_qp_debugfs_init(struct mlx5_core_dev *dev);
 void mlx5_qp_debugfs_cleanup(struct mlx5_core_dev *dev);
 int mlx5_access_reg(struct mlx5_core_dev *dev, void *data_in, int size_in,