brintos

brintos / linux-shallow public Read only

0
0
Text · 1.4 KiB · b973490 Raw
46 lines · c
1/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */2/*3 * Copyright (c) 2013-2020, Mellanox Technologies inc. All rights reserved.4 */5 6#ifndef _MLX5_IB_FS_H7#define _MLX5_IB_FS_H8 9#include "mlx5_ib.h"10 11#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)12int mlx5_ib_fs_init(struct mlx5_ib_dev *dev);13void mlx5_ib_fs_cleanup_anchor(struct mlx5_ib_dev *dev);14#else15static inline int mlx5_ib_fs_init(struct mlx5_ib_dev *dev)16{17	dev->flow_db = kzalloc(sizeof(*dev->flow_db), GFP_KERNEL);18 19	if (!dev->flow_db)20		return -ENOMEM;21 22	mutex_init(&dev->flow_db->lock);23	return 0;24}25 26inline void mlx5_ib_fs_cleanup_anchor(struct mlx5_ib_dev *dev) {}27#endif28 29static inline void mlx5_ib_fs_cleanup(struct mlx5_ib_dev *dev)30{31	/* When a steering anchor is created, a special flow table is also32	 * created for the user to reference. Since the user can reference it,33	 * the kernel cannot trust that when the user destroys the steering34	 * anchor, they no longer reference the flow table.35	 *36	 * To address this issue, when a user destroys a steering anchor, only37	 * the flow steering rule in the table is destroyed, but the table38	 * itself is kept to deal with the above scenario. The remaining39	 * resources are only removed when the RDMA device is destroyed, which40	 * is a safe assumption that all references are gone.41	 */42	mlx5_ib_fs_cleanup_anchor(dev);43	kfree(dev->flow_db);44}45#endif /* _MLX5_IB_FS_H */46