18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2019-2020, Mellanox Technologies inc. All rights reserved.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef _MLX5_IB_DEVX_H
78c2ecf20Sopenharmony_ci#define _MLX5_IB_DEVX_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include "mlx5_ib.h"
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define MLX5_MAX_DESTROY_INBOX_SIZE_DW MLX5_ST_SZ_DW(delete_fte_in)
128c2ecf20Sopenharmony_cistruct devx_obj {
138c2ecf20Sopenharmony_ci	struct mlx5_ib_dev	*ib_dev;
148c2ecf20Sopenharmony_ci	u64			obj_id;
158c2ecf20Sopenharmony_ci	u32			dinlen; /* destroy inbox length */
168c2ecf20Sopenharmony_ci	u32			dinbox[MLX5_MAX_DESTROY_INBOX_SIZE_DW];
178c2ecf20Sopenharmony_ci	u32			flags;
188c2ecf20Sopenharmony_ci	union {
198c2ecf20Sopenharmony_ci		struct mlx5_ib_devx_mr	devx_mr;
208c2ecf20Sopenharmony_ci		struct mlx5_core_dct	core_dct;
218c2ecf20Sopenharmony_ci		struct mlx5_core_cq	core_cq;
228c2ecf20Sopenharmony_ci		u32			flow_counter_bulk_size;
238c2ecf20Sopenharmony_ci	};
248c2ecf20Sopenharmony_ci	struct list_head event_sub; /* holds devx_event_subscription entries */
258c2ecf20Sopenharmony_ci};
268c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
278c2ecf20Sopenharmony_ciint mlx5_ib_devx_create(struct mlx5_ib_dev *dev, bool is_user);
288c2ecf20Sopenharmony_civoid mlx5_ib_devx_destroy(struct mlx5_ib_dev *dev, u16 uid);
298c2ecf20Sopenharmony_ciint mlx5_ib_devx_init(struct mlx5_ib_dev *dev);
308c2ecf20Sopenharmony_civoid mlx5_ib_devx_cleanup(struct mlx5_ib_dev *dev);
318c2ecf20Sopenharmony_ci#else
328c2ecf20Sopenharmony_cistatic inline int mlx5_ib_devx_create(struct mlx5_ib_dev *dev, bool is_user)
338c2ecf20Sopenharmony_ci{
348c2ecf20Sopenharmony_ci	return -EOPNOTSUPP;
358c2ecf20Sopenharmony_ci}
368c2ecf20Sopenharmony_cistatic inline void mlx5_ib_devx_destroy(struct mlx5_ib_dev *dev, u16 uid) {}
378c2ecf20Sopenharmony_cistatic inline int mlx5_ib_devx_init(struct mlx5_ib_dev *dev)
388c2ecf20Sopenharmony_ci{
398c2ecf20Sopenharmony_ci	return 0;
408c2ecf20Sopenharmony_ci}
418c2ecf20Sopenharmony_cistatic inline void mlx5_ib_devx_cleanup(struct mlx5_ib_dev *dev)
428c2ecf20Sopenharmony_ci{
438c2ecf20Sopenharmony_ci}
448c2ecf20Sopenharmony_ci#endif
458c2ecf20Sopenharmony_ci#endif /* _MLX5_IB_DEVX_H */
46