1*29422100SEli Cohen // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB 2*29422100SEli Cohen /* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ 3*29422100SEli Cohen 4*29422100SEli Cohen #include <linux/debugfs.h> 5*29422100SEli Cohen #include <linux/mlx5/fs.h> 6*29422100SEli Cohen #include "mlx5_vnet.h" 7*29422100SEli Cohen 8*29422100SEli Cohen static int tirn_show(struct seq_file *file, void *priv) 9*29422100SEli Cohen { 10*29422100SEli Cohen struct mlx5_vdpa_net *ndev = file->private; 11*29422100SEli Cohen 12*29422100SEli Cohen seq_printf(file, "0x%x\n", ndev->res.tirn); 13*29422100SEli Cohen return 0; 14*29422100SEli Cohen } 15*29422100SEli Cohen 16*29422100SEli Cohen DEFINE_SHOW_ATTRIBUTE(tirn); 17*29422100SEli Cohen 18*29422100SEli Cohen void mlx5_vdpa_remove_tirn(struct mlx5_vdpa_net *ndev) 19*29422100SEli Cohen { 20*29422100SEli Cohen if (ndev->debugfs) 21*29422100SEli Cohen debugfs_remove(ndev->res.tirn_dent); 22*29422100SEli Cohen } 23*29422100SEli Cohen 24*29422100SEli Cohen void mlx5_vdpa_add_tirn(struct mlx5_vdpa_net *ndev) 25*29422100SEli Cohen { 26*29422100SEli Cohen ndev->res.tirn_dent = debugfs_create_file("tirn", 0444, ndev->rx_dent, 27*29422100SEli Cohen ndev, &tirn_fops); 28*29422100SEli Cohen } 29*29422100SEli Cohen 30*29422100SEli Cohen static int rx_flow_table_show(struct seq_file *file, void *priv) 31*29422100SEli Cohen { 32*29422100SEli Cohen struct mlx5_vdpa_net *ndev = file->private; 33*29422100SEli Cohen 34*29422100SEli Cohen seq_printf(file, "0x%x\n", mlx5_flow_table_id(ndev->rxft)); 35*29422100SEli Cohen return 0; 36*29422100SEli Cohen } 37*29422100SEli Cohen 38*29422100SEli Cohen DEFINE_SHOW_ATTRIBUTE(rx_flow_table); 39*29422100SEli Cohen 40*29422100SEli Cohen void mlx5_vdpa_remove_rx_flow_table(struct mlx5_vdpa_net *ndev) 41*29422100SEli Cohen { 42*29422100SEli Cohen if (ndev->debugfs) 43*29422100SEli Cohen debugfs_remove(ndev->rx_table_dent); 44*29422100SEli Cohen } 45*29422100SEli Cohen 46*29422100SEli Cohen void mlx5_vdpa_add_rx_flow_table(struct mlx5_vdpa_net *ndev) 47*29422100SEli Cohen { 48*29422100SEli Cohen ndev->rx_table_dent = debugfs_create_file("table_id", 0444, ndev->rx_dent, 49*29422100SEli Cohen ndev, &rx_flow_table_fops); 50*29422100SEli Cohen } 51*29422100SEli Cohen 52*29422100SEli Cohen void mlx5_vdpa_add_debugfs(struct mlx5_vdpa_net *ndev) 53*29422100SEli Cohen { 54*29422100SEli Cohen struct mlx5_core_dev *mdev; 55*29422100SEli Cohen 56*29422100SEli Cohen mdev = ndev->mvdev.mdev; 57*29422100SEli Cohen ndev->debugfs = debugfs_create_dir(dev_name(&ndev->mvdev.vdev.dev), 58*29422100SEli Cohen mlx5_debugfs_get_dev_root(mdev)); 59*29422100SEli Cohen if (!IS_ERR(ndev->debugfs)) 60*29422100SEli Cohen ndev->rx_dent = debugfs_create_dir("rx", ndev->debugfs); 61*29422100SEli Cohen } 62*29422100SEli Cohen 63*29422100SEli Cohen void mlx5_vdpa_remove_debugfs(struct dentry *dbg) 64*29422100SEli Cohen { 65*29422100SEli Cohen debugfs_remove_recursive(dbg); 66*29422100SEli Cohen } 67