Add a debugfs directory for flow steering related information.
The directory is currently empty, and will hold the 'tc' subdirectory in
a downstream patch.
Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
 
 struct mlx5e_flow_steering *mlx5e_fs_init(const struct mlx5e_profile *profile,
                                          struct mlx5_core_dev *mdev,
-                                         bool state_destroy);
+                                         bool state_destroy,
+                                         struct dentry *dfs_root);
 void mlx5e_fs_cleanup(struct mlx5e_flow_steering *fs);
 struct mlx5e_vlan_table *mlx5e_fs_get_vlan(struct mlx5e_flow_steering *fs);
 void mlx5e_fs_set_tc(struct mlx5e_flow_steering *fs, struct mlx5e_tc_table *tc);
                              __be16 proto, u16 vid);
 void mlx5e_fs_init_l2_addr(struct mlx5e_flow_steering *fs, struct net_device *netdev);
 
+struct dentry *mlx5e_fs_get_debugfs_root(struct mlx5e_flow_steering *fs);
+
 #define fs_err(fs, fmt, ...) \
        mlx5_core_err(mlx5e_fs_get_mdev(fs), fmt, ##__VA_ARGS__)
 
 
  * SOFTWARE.
  */
 
+#include <linux/debugfs.h>
 #include <linux/list.h>
 #include <linux/ip.h>
 #include <linux/ipv6.h>
        struct mlx5e_fs_udp            *udp;
        struct mlx5e_fs_any            *any;
        struct mlx5e_ptp_fs            *ptp_fs;
+       struct dentry                  *dfs_root;
 };
 
 static int mlx5e_add_l2_flow_rule(struct mlx5e_flow_steering *fs,
        return addr[5];
 }
 
+struct dentry *mlx5e_fs_get_debugfs_root(struct mlx5e_flow_steering *fs)
+{
+       return fs->dfs_root;
+}
+
 static void mlx5e_add_l2_to_hash(struct hlist_head *hash, const u8 *addr)
 {
        struct mlx5e_l2_hash_node *hn;
 static void mlx5e_fs_ethtool_free(struct mlx5e_flow_steering *fs) { }
 #endif
 
+static void mlx5e_fs_debugfs_init(struct mlx5e_flow_steering *fs,
+                                 struct dentry *dfs_root)
+{
+       if (IS_ERR_OR_NULL(dfs_root))
+               return;
+
+       fs->dfs_root = debugfs_create_dir("fs", dfs_root);
+}
+
 struct mlx5e_flow_steering *mlx5e_fs_init(const struct mlx5e_profile *profile,
                                          struct mlx5_core_dev *mdev,
-                                         bool state_destroy)
+                                         bool state_destroy,
+                                         struct dentry *dfs_root)
 {
        struct mlx5e_flow_steering *fs;
        int err;
        if (err)
                goto err_free_tc;
 
+       mlx5e_fs_debugfs_init(fs, dfs_root);
+
        return fs;
 err_free_tc:
        mlx5e_fs_tc_free(fs);
 
 void mlx5e_fs_cleanup(struct mlx5e_flow_steering *fs)
 {
+       debugfs_remove_recursive(fs->dfs_root);
        mlx5e_fs_ethtool_free(fs);
        mlx5e_fs_tc_free(fs);
        mlx5e_fs_vlan_free(fs);
 
        mlx5e_timestamp_init(priv);
 
        fs = mlx5e_fs_init(priv->profile, mdev,
-                          !test_bit(MLX5E_STATE_DESTROYING, &priv->state));
+                          !test_bit(MLX5E_STATE_DESTROYING, &priv->state),
+                          priv->dfs_root);
        if (!fs) {
                err = -ENOMEM;
                mlx5_core_err(mdev, "FS initialization failed, %d\n", err);
 
 {
        struct mlx5e_priv *priv = netdev_priv(netdev);
 
-       priv->fs = mlx5e_fs_init(priv->profile, mdev,
-                                !test_bit(MLX5E_STATE_DESTROYING, &priv->state));
+       priv->fs =
+               mlx5e_fs_init(priv->profile, mdev,
+                             !test_bit(MLX5E_STATE_DESTROYING, &priv->state),
+                             priv->dfs_root);
        if (!priv->fs) {
                netdev_err(priv->netdev, "FS allocation failed\n");
                return -ENOMEM;
        struct mlx5e_priv *priv = netdev_priv(netdev);
 
        priv->fs = mlx5e_fs_init(priv->profile, mdev,
-                                !test_bit(MLX5E_STATE_DESTROYING, &priv->state));
+                                !test_bit(MLX5E_STATE_DESTROYING, &priv->state),
+                                priv->dfs_root);
        if (!priv->fs) {
                netdev_err(priv->netdev, "FS allocation failed\n");
                return -ENOMEM;
 
        int err;
 
        priv->fs = mlx5e_fs_init(priv->profile, mdev,
-                                !test_bit(MLX5E_STATE_DESTROYING, &priv->state));
+                                !test_bit(MLX5E_STATE_DESTROYING, &priv->state),
+                                priv->dfs_root);
        if (!priv->fs) {
                netdev_err(priv->netdev, "FS allocation failed\n");
                return -ENOMEM;