18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2013-2018, Mellanox Technologies. All rights reserved.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef MLX5_IB_SRQ_H
78c2ecf20Sopenharmony_ci#define MLX5_IB_SRQ_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_cienum {
108c2ecf20Sopenharmony_ci	MLX5_SRQ_FLAG_ERR    = (1 << 0),
118c2ecf20Sopenharmony_ci	MLX5_SRQ_FLAG_WQ_SIG = (1 << 1),
128c2ecf20Sopenharmony_ci	MLX5_SRQ_FLAG_RNDV   = (1 << 2),
138c2ecf20Sopenharmony_ci};
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cistruct mlx5_srq_attr {
168c2ecf20Sopenharmony_ci	u32 type;
178c2ecf20Sopenharmony_ci	u32 flags;
188c2ecf20Sopenharmony_ci	u32 log_size;
198c2ecf20Sopenharmony_ci	u32 wqe_shift;
208c2ecf20Sopenharmony_ci	u32 log_page_size;
218c2ecf20Sopenharmony_ci	u32 wqe_cnt;
228c2ecf20Sopenharmony_ci	u32 srqn;
238c2ecf20Sopenharmony_ci	u32 xrcd;
248c2ecf20Sopenharmony_ci	u32 page_offset;
258c2ecf20Sopenharmony_ci	u32 cqn;
268c2ecf20Sopenharmony_ci	u32 pd;
278c2ecf20Sopenharmony_ci	u32 lwm;
288c2ecf20Sopenharmony_ci	u32 user_index;
298c2ecf20Sopenharmony_ci	u64 db_record;
308c2ecf20Sopenharmony_ci	__be64 *pas;
318c2ecf20Sopenharmony_ci	u32 tm_log_list_size;
328c2ecf20Sopenharmony_ci	u32 tm_next_tag;
338c2ecf20Sopenharmony_ci	u32 tm_hw_phase_cnt;
348c2ecf20Sopenharmony_ci	u32 tm_sw_phase_cnt;
358c2ecf20Sopenharmony_ci	u16 uid;
368c2ecf20Sopenharmony_ci};
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_cistruct mlx5_ib_dev;
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cistruct mlx5_core_srq {
418c2ecf20Sopenharmony_ci	struct mlx5_core_rsc_common common; /* must be first */
428c2ecf20Sopenharmony_ci	u32 srqn;
438c2ecf20Sopenharmony_ci	int max;
448c2ecf20Sopenharmony_ci	size_t max_gs;
458c2ecf20Sopenharmony_ci	size_t max_avail_gather;
468c2ecf20Sopenharmony_ci	int wqe_shift;
478c2ecf20Sopenharmony_ci	void (*event)(struct mlx5_core_srq *srq, enum mlx5_event e);
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci	u16 uid;
508c2ecf20Sopenharmony_ci};
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cistruct mlx5_srq_table {
538c2ecf20Sopenharmony_ci	struct notifier_block nb;
548c2ecf20Sopenharmony_ci	struct xarray array;
558c2ecf20Sopenharmony_ci};
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ciint mlx5_cmd_create_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
588c2ecf20Sopenharmony_ci			struct mlx5_srq_attr *in);
598c2ecf20Sopenharmony_ciint mlx5_cmd_destroy_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq);
608c2ecf20Sopenharmony_ciint mlx5_cmd_query_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
618c2ecf20Sopenharmony_ci		       struct mlx5_srq_attr *out);
628c2ecf20Sopenharmony_ciint mlx5_cmd_arm_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
638c2ecf20Sopenharmony_ci		     u16 lwm, int is_srq);
648c2ecf20Sopenharmony_cistruct mlx5_core_srq *mlx5_cmd_get_srq(struct mlx5_ib_dev *dev, u32 srqn);
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ciint mlx5_init_srq_table(struct mlx5_ib_dev *dev);
678c2ecf20Sopenharmony_civoid mlx5_cleanup_srq_table(struct mlx5_ib_dev *dev);
688c2ecf20Sopenharmony_ci#endif /* MLX5_IB_SRQ_H */
69